WinForm中ListView的使用

  • 每一行是一个ListViewItem对象,每一项是一个ListViewSubItem对象
  • 样式
    • 整行选择:this.lvDataSourceSearchHistory.FullRowSelect = true;
    • 文本是否可编辑:this.lvDataSourceSearchHistory.LabelEdit = false;
    • 隐藏列头:this.lvDataSourceSearchHistory.HeaderStyle = ColumnHeaderStyle.None;
    • 边框样式:this.lvDataSourceSearchHistory.BorderStyle = BorderStyle.Fixed3D;
  • 绑定数据
    • this.lvDataSourceSearchHistory.Columns.Clear();
    • this.lvDataSourceSearchHistory.Columns.Add("Search Text");
    • this.lvDataSourceSearchHistory.Columns.Add("Delete Button");
    • 固定宽度:this.lvDataSourceSearchHistory.Columns[0].Width = 440;
    • 固定宽度:this.lvDataSourceSearchHistory.Columns[1].Width = 15;
  • 自定义显示每一行每一项的显示
    • 先要设置this.OwnerDraw = true;才能重绘每一项
原文地址:https://www.cnblogs.com/wyp1988/p/9875350.html