Can't handle events of Dialog Box Controls - WinForms C# -


i error when make method or add eventhandler control added on dialog box. make clearer, dialog looks this:

public static class promptmonth { public static string showmonthdialog(string caption) {     form prompt = new form()     {         width = 200,         height = 150,         formborderstyle = formborderstyle.fixeddialog,         text = caption,         startposition = formstartposition.centerparent     };     label textlabel = new label() { left = 25, top = 10, text = "pick month" };     combobox combomonth = new combobox() { left = 25, top = 35 };     button ok = new button() { text = "ok", left = 25, width = 100, top = 70, dialogresult = dialogresult.ok };      ok.click += (sender, e) => { prompt.close(); };     textlabel.autosize = true;      combomonth.dropdownstyle = comboboxstyle.dropdownlist;      combomonth.items.add("january");     combomonth.items.add("february");     combomonth.items.add("march");     combomonth.items.add("april");     combomonth.items.add("may");     combomonth.items.add("june");     combomonth.items.add("july");     combomonth.items.add("august");     combomonth.items.add("september");     combomonth.items.add("october");     combomonth.items.add("november");     combomonth.items.add("december");     combomonth.selecteditem = month; // month = current month      prompt.controls.add(textlabel);     prompt.controls.add(combomonth);     prompt.controls.add(ok);      prompt.acceptbutton = ok;     prompt.showdialog();      return combomonth.text; } } 

that's code makes dialog, , in case, call this:

string promptmonth = promptmonth.showmonthdialog("month"); 

that's dialog far without trying add method, if try add event handler for, let's say, combomonth combobox this:

combomonth.selectedindexchanged += new eventhandler(combomonth_selectedindexchanged);      private void combomonth_selectedindexchanged(object sender, eventargs e)     {         //     } 

and type right beneath prompt.acceptbutton = ok; i'll these errors:

img1

img2

i tried googling possibility of making whole brand new form, brand new project, populate form whatever wanted (and make act want dialog act like) , form1.cs included in code or that. understand dialogs not meant complex require popup window want methods , event handlers.

thank in advance , sorry making long, wanted make clear possible.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -