ComboBox SelectedItemIndex上的DrawLine

时间:2014-05-12 10:56:44

标签: c# combobox devexpress

只是想知道我是否可以在组合框的选择索引上绘制线条。

ss:http://oi59.tinypic.com/lzdxj.jpg

referring to screenshot above:
number1 -|> i want to achieve
number2 -|> current output that i have for combobox using this code:

示例代码:

void ComboBox1_DrawItem(object sender, ListBoxDrawItemEventArgs e)
{
float[] location = new float[4];
            Pen pen = new Pen(Color.FromArgb(255, 255, 255, 255), 2f);
            if (e.Item.ToString() == "2")
            {
                var q = e.Bounds;
                pen = new Pen(Color.FromArgb(255, 255, 255, 255), 2f);

                //Rectangle r = e.Bounds;
                var x = ComboBox1.Size.Width - 13;
                location[0] = 10;
                location[1] = (e.Bounds.Y / 2) + ((e.Bounds.Y + e.Bounds.Height) / 2) + .5f;
                location[2] = x;
                location[3] = (e.Bounds.Y / 2) + ((e.Bounds.Y + e.Bounds.Height) / 2) + .5f;
                e.Graphics.DrawLine(pen, location[0], location[1], location[2], location[3]);
                e.Handled = true;
            }

 if (e.State != DrawItemState.Selected) return;
            e.Cache.FillRectangle(Color.FromArgb(83, 83, 83), e.Bounds);
            e.Graphics.DrawLine(pen, location[0], location[1], location[2], location[3]);
            e.Handled = true;

}

我怎样才能实现它?

注意:

  

我正在使用DevExpress ComboBoxEdit

0 个答案:

没有答案