(1) How to add the available fonts in the computer to the ComboBox in WinForm:
A word is done: ComboBox1.Items.AddRange (fontfamily.families);
(2) Get all available colors and populate the ASP.net drop-down menu:
Copy Code code as follows:
Propertyinfo[] Properties;
ArrayList colors;
Color color;
SolidBrush Brush;
Properties = typeof (Color). GetProperties (BindingFlags.Public | BindingFlags.Static);
colors = new ArrayList ();
foreach (PropertyInfo prop in properties)
{
Get the value of this static
color = (color) Prop. GetValue (null, NULL);
Skip colors that are not interesting
if (color = = color.transparent) continue;
if (color = = Color.Empty) continue;
Try
{
DDLLIST.ITEMS.ADD (Prop. Name);
}
Catch
{
}
Create a solid brush of this color
Brush = new SolidBrush (color);
Colors. ADD (brush);
}
(3) How to get the connection string of the database?
A. Create a new text file with the filename *.udl (for example: mydb.udl), where the icon becomes the icon of the database connection.
B. Double-click the file to eject the dialog for the properties of the data connection, and you can set it now. Generally, we first select the "Provider" tab, after setting, and then set the related properties of the Connection tab, I will not say anything else. When you have set it up, press OK at the end. There may be a corresponding hint, you can do it yourself.
C. Use Notepad to open the file you just made. There's a string like this:
Provider=SQLOLEDB.1; PASSWORD=123456SA; Persist Security info=true; User id=sa;initial Catalog=zpweb;data Source=myservername
If you use the SQL Server database, change provider=sqloledb.1 to: server=localhost;