Hi All.
I just started to study on C# and I have an Application on WPF which reads datas in my XML. I read the datas with Dataset and I put them in to a ComboBox. But i have some shapes (Elipse) and I want to fill that shapes different colors if there the data which i want in ComboBox.
--
DataSet ds = new DataSet();
ds.ReadXml("D:\\data.xml");
foreach (DataTable tbl in ds.Tables)
{
foreach (DataRow dr in tbl.Rows)
{
cmb1.Items.Add(dr[0].ToString());
}
}
After adding items to ComboBox. For Example I want to fill Elipse1 with Red Color If There is Elipse1 item in ComboBox which comes from XML.
Is there anyone to help me :( ??
Thanks.
Posted Sep 24, 2010, 5:12 AM
I have doubt...wat data will in the combo box...either colours or shapes.????????.
Some suggestions ---In the form load event fill the combo-box from xml and in the combo box selected index change event fill the shapes with the colors u want...
With Regards
P.Krishna Prasad
Posted Sep 24, 2010, 6:11 AM
Two ways to do it...
First way is
if(ComboBox.SelectedItem.ToString()== "Elipse1")
{
Elipse1.Fill = new SolidColorBrush(Colors.Blue);
}
if(ComboBox.SelectedItem.ToString()== "Rectangle")
{
Rectangle.Fill = new SolidColorBrush(Colors.Blue);
}
Secondway is
if(ComboBox.SelectedIndex==0)
{
Elipse1.Fill = new SolidColorBrush(Colors.Blue);
}
if(ComboBox.SelectedIndex==1)
{
Rectangle.Fill = new SolidColorBrush(Colors.Blue);
}
Hope i made myself clear...
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
If someway my answer helped u....don't forget to mark it as correct answer....
Guest UserPosted Sep 24, 2010, 5:20 AM
i cant compare it.
if(ComboBox.SelectedItem.ToString()== !! What !!)
{
Elipse1.Fill = new SolidColorBrush(Colors.Blue);
}
I want sth like that ...
Events are OK, Taking the datas with DataSet is OK. But I cant Compare ..
Thanks.