Asp. NET get all color values sample _ Practical Tips

Source: Internet
Author: User
(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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.