|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Jiří Konečný
|
Aug 20, 2013 - 4:54 AM
|
Hi if you can please help me. I created combobox as color picker it works well in dropdown list but when I select something then only a string is shown (not the colors). I tried to use images but the problem was the same.
Items are normal strings with color names
public void FillDraw() { comboBox1.Items.Add("Blue"); comboBox1.Items.Add("Green"); comboBox1.Items.Add("Orange"); }
and I’m using DrawItem event like this:
protected void comboBox1_DrawItem(object sender, Elegant.Ui.DrawComboBoxItemEventArgs e) { Graphics g = e.Graphics; Rectangle rect = e.Bounds;
if (e.ItemIndex < 0) return;
string col = ((Elegant.Ui.ComboBox)sender).Items[e.ItemIndex].ToString(); Font f = new Font("Arial", 9.75f, FontStyle.Regular);
if (e.IsSelected) e.PaintSelectedBackground();
if (e.ItemIndex >= 0) { Color c = Color.FromName(col); Brush b = new SolidBrush(c); Pen p = new Pen(Color.Black); g.DrawString(col, f, Brushes.Black, rect.X, rect.Top); g.FillRectangle(b, rect.X + 50, rect.Y + 2, rect.Width - 20, rect.Height - 4); g.DrawRectangle(p, rect.X + 50, rect.Y + 2, rect.Width - 20, rect.Height - 4); } }
I changed ComboBox properties DrawMode to OwnerDrawFixed and Editable to False.
Thank you for reply.
|
|
Jiří Konečný
|
Aug 20, 2013 - 5:08 AM
|
Image version now working correctly (I forget to set SelectedImageSize) but if someone know how to draw items directly it will be better for my solution.
|
|