c# - Call a method inside an event handler function -
i'm trying implement application in c# generates me qr code. i've managed this, don't know how call createqrimage(string inputdata) inside genbutton_click(object sender, eventargs e).
i inside windows form have textbox , button, , think function createqrimage must called name of textbox
here code:
private void genbutton_click(object sender, eventargs e) { } public void createqrimage(string inputdata) { if (inputdata.trim() == string.empty) { system.windows.forms.messagebox.show("data must not empty."); } barcodewriter qrcoder = new zxing.barcodewriter { format = barcodeformat.qr_code, options = new zxing.qrcode.qrcodeencodingoptions { errorcorrection = zxing.qrcode.internal.errorcorrectionlevel.h, height = 250, width = 250 } }; string tempfilename = system.io.path.gettemppath() + inputdata + ".png"; image image; string data = inputdata; var result = qrcoder.write(inputdata); image = new bitmap(result); image.save(tempfilename); system.diagnostics.process.start(tempfilename); }
this should trick:
private void genbutton_click(object sender, eventargs e) { // assuming text box name. assuming ui disables button until text entered. this.createqrimage(mytextbox.text); }
Comments
Post a Comment