开发者

Runtime control population using XML in winform application

A thought came in mind, is there any way to populate control in runtime using XML. I mean I will have one Controls.xml file and in that file I can define what control i want to add to a perticular winform and when we run that 开发者_开发技巧app it will show exact controls. Has anyone done this? Please guide me on this.


Yes, you can create the controls dynamically: all you need to do is to parse the XML and then create them.

TextBox tb = new TextBox();
tb.Location = new Point(25,25);
tb.Click += textbox_Click;
this.Controls.Add (tb);


You can Serialize a Control (which is an Object) to XML than Deserialize se HOW TO

But the issue would be Event's ,where you should use Reflection and/or Code Injection into the Application because Event's cannot get Deserialized as an Object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜