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;才能重绘每一项

 

posted on 2018-10-30 10:29  碎羽love星谊  阅读(273)  评论(0编辑  收藏  举报

导航