Sunday, October 28, 2012

bind all font name to list box in asp.net using C#.net

In this post i will show how to Display all font name in list box  and based on the selection show the preview in label.To get the font name we have add the name space for Drawing class

Using System.Drawing.Text;
Using System.Collection;

Private void from_load(..)
{
InstalledFontCollection ifcn=new InstalledFontCollection()
IEnumerator ien;
ien=ifcn.Families.GetEnumerator();
While(ien.MoveNext()==true)
{
string si=ien.Current.Tostring();
int i=si.IndexOf("=");
si=si.Substring(i+1);
si=si.Substring(0,si.Lenght-1);
ListBox1.Items.Add(si);
}
}
//list box selected index changed event code
{
String sres=ListBox1.SelectedItem.Tostring();
Lbl.Form=new font(sres,40);
}
Post a Comment

Bel