0
我有dropdownstyle的組合框 - dropdownlist它是不可編輯的,但在Windows 7中,它的背景色不能改變。所以我想要一個不可編輯的下拉組合框。如何製作不可編輯的下拉式組合框?
我有dropdownstyle的組合框 - dropdownlist它是不可編輯的,但在Windows 7中,它的背景色不能改變。所以我想要一個不可編輯的下拉組合框。如何製作不可編輯的下拉式組合框?
有設置背景色
首先方式
設置組合框屬性雙向
comboBox1.DrawMode = DrawMode.OwnerDrawFixed;
然後實現DRAWITEM事件處理程序(下面示例代碼)
private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index > -1)
{
e.DrawBackground();
e.Graphics.DrawString(comboBox1.Items[e.Index].ToString(), this.Font, Brushes.Black, e.Bounds);
e.DrawFocusRectangle();
}
}
方式二 設置組合框屬性
comboBox1.FlatStyle = FlatStyle.Flat;
然後使用你需要在你的組合框組合框
逗留背景色和屬性窗口中搜索dropstyle屬性,然後選擇下拉列表;
你能澄清這個問題嗎?它有點含糊。 – lnu