tags:

views:

542

answers:

1

Hi, i want to draw simple circle of different category size of circle come form database and different size in c#.net for desktop for winforms ..

as you saw me how to draw circle using listbox now i want to fill color in List box each circle using another List box when color is defined ....it is multiple color also we can apply .. please help me in this..

+2  A: 

Set DrawMode property and handle DrawItem event of ListBox,

 private void Form1_Load(object sender, EventArgs e)
        {
            listBox1.DrawMode = DrawMode.OwnerDrawVariable;
            listBox1.Items.Add("One");
            listBox1.Items.Add("Two");
            listBox1.Items.Add("Three");
            listBox1.DrawItem += new DrawItemEventHandler(listBox1_DrawItem);    
        }

        void listBox1_DrawItem(object sender, DrawItemEventArgs e)
        {
            ListBox l=sender as ListBox;
            e.DrawBackground();
            e.DrawFocusRectangle();
            e.Graphics.DrawEllipse(Pens.Blue, new Rectangle(1, 1+e.Index * 15, 100, 10));
            e.Graphics.DrawString(l.Items[e.Index].ToString(), new Font(FontFamily.GenericSansSerif,9, FontStyle.Regular), Brushes.Red , e.Bounds);
        }
adatapost
thanks its working fine
Yagnesh84
vote down star Hi, i want to draw simple circle of different category size of circle come form database and different size in c#.net for desktop for winforms ..as you saw me how to draw circle using listbox now i want to fill color in List box each circle using another List box when color is defined ....it is multiple color also we can apply .. please help me in this..
Yagnesh84