c# - Adding textBox in runtime and save changes -


I am developing a Windows project project for which the user can add new fields (text box and label) by clicking a button. What I want to achieve, after the user added a new field, a textbox is automatically created and saved in the settings of my form. So when I will run my project again The newly added text box (from runtime) is available. Are there any possible ways to do this? I'm new to C # thanks in advance!

you try this

DataTable System.Data < Pre> system Using data; Settings "); // We use datatableable dt.Column.Add ("ID"); Dt.Columns.Add ("Control"); Dt.Columns.Add ("controlname"); Dt.Columns.Add ("Top"); Dt.Columns.Add ("left"); Dt.Columns.Add ("width"); Dt.Columns.Add ("height"); / * * You can add more settings here * / int id = 0; Foreach (Control ctrl.Controls in this) //this.Controls is the basic control where the text box is located {string c = ctrl.GetType (). Name; Switch (C) {Case "Text Box": Detrovert Dr = DT. NRO (); Dr. ["id"] = ID ++; Dr. ["control"] = C; Dr ["ControlName"] = ctrlName; Dr. ["top"] = ctrl.Top; Dr. ["left"] = ctrl.Left; Dr. ["width"] = ctrl.Width; Dr. ["height"] = ctrl.Height; / * * You can add more settings here * / dt.Rows.Add (dr); break; }} Dt.WriteXml (@ "c: \ TestFile.xml", XmlWriteMode.WriteSchema); // You can use the save dialog to browse the location}

to retrieve

  Private Zero Button 2_Click (Object Sender, Eventarges) e) {Datatable DT = New Datatile ("Settings"); ;: Dt.ReadXml ("\ TestFile.xml c" @) Foreign Currency (Detroor DR in DT.RO) {Switch (DR ["Control"]. Toasting ()) {Case "Textbox": var t = New Text Box (); T.Name = dr ["ControlName"]. ToString (); T. Tap = convert toint32 (dr ["top"]); T.Left = Convert.ToInt32 (Dr. ["left"]); T.Width = Convert. ToInt32 (dr ["width"]); T. Het = convert.toInt32 (dr ["height"]); This.Controls.Add (t); break; }}}  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -