ObjectListView的使用

1.引入ObjectListView.dll



2.使用

把objectlistview拖入到窗体

加入列,


objectlistview显示数据必须要和一个对象绑定,objectListView1.SetObjects(object);

而每一列的显示对应一个成员变量

aspectName必须与object的成员变量Title关联,才可以显示出数据,所以,aspectName栏必须填入Title。

加入过程:

MyObject myObject = new MyObject();
            myObject.nameString = "yrf";
            myObject.ageString = "12";
            List<MyObject> list = new List<MyObject>();
            list.Add(myObject);
            objectListView1.SetObjects(list);



是否显示组:

this.olvComplex.ShowGroups = false;


当鼠标放在某一行,颜色会改变的效果
this.olvSimple.UseHotItem = true;
this.olvSimple.HotItemStyle = this.hotItemStyle1;

OLVColumn增加一列,表格中的一列

olvJokeColumn

加入图片
1.ObjectListView‘s SmallImageList
2.
this.titleColumn.ImageGetter = delegate (object rowObject) {
                Song s = (Song)rowObject;
                if (s.Rating >= 80)
                    return "star";
                else
                    return "song";
            };

加入checkbox:

1.this.olvComplex.OwnerDraw = true;

2.this.olvComplex.UseSubItemCheckBoxes = true;

3.this.olvJokeColumn.CheckBoxes = true;

4.响应事件:SubItemChecking


改变某一列的颜色和字体:

To change the formatting of an individual cell, you need to setUseCellFormatEvents totrue and then listen forFormatCell events.To show just the credit balance in red, you could do something like this:

private void olv1_FormatCell(object sender, FormatCellEventArgs e) {
    if (e.ColumnIndex == this.creditBalanceColumn.Index) {
        Customer customer = (Customer)e.Model;
        if (customer.Credit < 0)
            e.SubItem.ForeColor = Color.Red;
    }
}

行高:

RowHeight


去掉头部:

headstyle


改变头部样式:

Make sure HeaderUsesThemes is false

HeaderFormatStyle


点击行事件的响应:

1.Click事件

2.objectListView1.HotRowIndex


改变表格头部的颜色:

The colours used to indicate a selected row are governed by the operating system andcannot be changed. However, if you set UseCustomSelectionColors to true, theObjectListView will use HighlightBackgroundColor and HighlightForegroundColor asthe colours for the selected rows.



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值