.net - dynamically create button at runtime and store , retrieve it permenantly in c# -
i have create button dynamically @ run time. when close , reopen buttons gone. how store permanently dynamically created buttons , other controls.
dynamically create control button code is:
int loc=150; private void button1_click(object sender, eventargs e){ createdynamicbutton(); } private void createdynamicbutton() { // create button object button dynamicbutton = new button(); // set button properties dynamicbutton.height = 40; dynamicbutton.width = 300; dynamicbutton.backcolor = color.red; dynamicbutton.forecolor = color.blue; dynamicbutton.location = new point(20, loc); loc=loc+50; dynamicbutton.text = "i dynamic button"; dynamicbutton.name = "dynamicbutton"; dynamicbutton.font = new font("georgia", 16); // add button click event handler dynamicbutton.click += new eventhandler(dynamicbutton_click); // add button form. placement of button // based on location , size of button controls.add(dynamicbutton); } /// <summary> /// button click event handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dynamicbutton_click(object sender, eventargs e) { messagebox.show("dynamic button clicked"); propertygrid1.selectedobject=sender; *****and change color fontsize in propertygrid1 changed *****how save permanently }
please me how store controls permanently(control color,position,name ... )
thanks in advance.
you can't really, or not dynamic. need call code every time need button. can store in file or table if want.
in example, there not need button dynamic far can judge. perhaps intended example
Comments
Post a Comment