1.设置属性

            // 1、属性设置 DrawMode ->OwnerDrawVariable
            this.cboBoxPostID.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
            this.cboBoxPostID.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.cboBoxPostID_DrawItem);

2.DrawItem事件

     private void cboBoxPostID_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }
            e.DrawBackground();
            e.DrawFocusRectangle();
            e.Graphics.DrawString(cboBoxPostID.GetItemText(cboBoxPostID.Items[e.Index]).ToString(), e.Font, new SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y + 3);
        }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-03
  • 2021-04-15
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2022-02-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案