Hi,,
I want to set windows form background color through variable like bellow..
adpt = new SqlDataAdapter("select bgcolor from colorschem",conn);
dt = new DataTable();
adpt.Fill(dt);
if (dt.Rows.Count > 0)
{
string a;
foreach (DataRow row in dt.Rows)
{
a = (row[0].ToString());
}
this.backcolor=color.red;
//here i want to assign the variable value just like a variable...
so how it is possible...?
}
any body help...
Loading

VulpesRank #55 · 29.2K reputationPosted May 30, 2011, 4:07 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 28, 2011, 2:34 AM EDT
Kanhialal kkRank #8,477 · 221 reputationPosted May 28, 2011, 2:50 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 28, 2011, 3:16 AM EDT
this.BackColor = (System.Drawing.Color) Enum.Parse(typeof(System.Drawing.Color), a);
Kanhialal kkRank #8,477 · 221 reputationPosted May 28, 2011, 3:27 AM EDT
Argument Exception was unhandled...
Type provided must be an Enum.
Parameter name: enumType
VulpesRank #55 · 29.2K reputationPosted May 28, 2011, 3:44 AM EDT
Try this instead:
this.BackColor = Color.FromName(a);
Kanhialal kkRank #8,477 · 221 reputationPosted May 29, 2011, 8:17 PM EDT
Control does not support transparent background colors.
VulpesRank #55 · 29.2K reputationPosted May 30, 2011, 1:47 AM EDT
Can you tell me exactly what's being stored in the database because it can't be something simple such as "Red" or "Blue".
Kanhialal kkRank #8,477 · 221 reputationPosted May 30, 2011, 3:42 AM EDT
while database column like(BGCOLOR(varchar)200);
ff6f97bf
Kanhialal kkRank #8,477 · 221 reputationPosted May 30, 2011, 8:01 PM EDT