Showing posts with label C#.net. Show all posts
Showing posts with label C#.net. Show all posts

Thursday, November 27, 2008

Load Objects From Xml on Runtime

today I finally finished the designer project which was a portable VS.Net Designer But from xml.
the big problem was to create a control with specified properties in format of string and add them to a form. that really was on my nurves for 2 weeks.
I'm going to put the most important part here.
I hope this be useful for you.


PropertyInfo pi = control.GetType().GetProperty("Cursor");
TypeConverter convertor = TypeDescriptor.GetConverter(pi.PropertyType);
object arg = convertor.ConvertFromString("Hand");
control.GetType().InvokeMember("Cursor", BindingFlags.SetProperty, null, control, new object[] {arg});

"Cursor" is property of control which is instantiated from assembly in runtime.
as you can see everything is made and set by string.