Thursday, September 3, 2009

TypeDescriptor.GetConverter - unified way of converting types of values to other types

...
string[] brdrStyleAry = Enum.GetNames(typeof(BorderStyle));
rbtnBrdr.DataSource = brdrStyleAry;
rbtnBrdr.DataBind();
...
TypeConverter objCnvrtr =
TypeDescriptor.GetConverter(typeof(BorderStyle));
pnlCard.BorderStyle =
(BorderStyle) objCnvrtr.ConvertFromString(rbtnBrdr.SelectedItem.Text);

Share/Bookmark

No comments: