WinForm中ListBox的使用

  • 获取选中数据:listbox.SelectedItem as XXX
  • 重绘每一行item
    • DrawMode设置为DrawMode.OwnerDrawVariable
    • 然后实现DrawItem(object sender, DrawItemEventArgs e)
    • 重绘选中行(鼠标所在行),如修改选中行的背景色
      •  1             if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
         2             {
         3                 e = new DrawItemEventArgs(e.Graphics,
         4                                   e.Font,
         5                                   e.Bounds,
         6                                   e.Index,
         7                                   e.State ^ DrawItemState.Selected,
         8                                   e.ForeColor,
         9                                   DataSourceUIParams.TableRowBackColorWhenHover);
        10             }
        11 
        12             e.DrawBackground();
        View Code
    • 重绘所有行

posted on 2018-11-05 16:51  碎羽love星谊  阅读(367)  评论(0编辑  收藏  举报

导航