c# - How to create labels once a GUI button is pressed? -


i have gui button can detect when pressed , piece of code want have create labels when button pressed. i'm converting entry int (this working. tested displaying int in entry.) , trying use loop. code in source code of main window. here code:

using system; using gtk;  public partial class mainwindow: gtk.window { public mainwindow () : base (gtk.windowtype.toplevel) {     build (); }  protected void ondeleteevent (object sender, deleteeventargs a) {     application.quit ();     a.retval = true; }  protected void generateplates (object sender, eventargs e) {     int n;     short number;     bool validnumnber;      if (int16.tryparse (entry1.text, out number))     {         validnumnber = true;     }     else      {         validnumnber = false;     }      if (validnumnber == true)     {         n = int16.parse(entry1.text);     }     else     {         n = 0;     }      (int = 0; < n; i++)     {         var lbl = new label();         lbl.name = "lbl"+i;         lbl.text = "plate "+i+":";         lbl.allocation = new gdk.rectangle (110*i+110,110*i+110,100,100);         this.add (lbl);          entry3.text = this.tostring();     } } 

any advice appreciated , feel free ask more details. if code has other flaws in it, please let me know complete novice. entry3 entry i'm using testing this.

edit: code windows desktop app.

in general, need add new control form/view/whatever's collection of controls. if running in view use. view.add (lbl);

if using c#.net winforms (which don't think are) use this.controls.add(lbl);


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -