发布:2024/6/28 21:23:01作者:管理员 来源:本站 浏览次数:263
显示行号类
/// <summary>
/// GridView 显示行号 设置行号列的宽度
/// </summary>
/// <param name="gv">GridView 控件名称</param>
/// <param name="width">行号列的宽度 如果为null或为0 默认为30</param>
public void DrawRowIndicator(DevExpress.XtraGrid.Views.Grid.GridView gv, int width) {
gv.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gv_CustomDrawRowIndicator);
if (width != null)
{
if (width != 0)
{
gv.IndicatorWidth = width;
}
else {
gv.IndicatorWidth = 30;
}
}
else {
gv.IndicatorWidth = 30;
}
}
//行号设置
private void gv_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e) {
if (e.Info.IsRowIndicator && e.RowHandle > -1) {
e.Info.DisplayText = (e.RowHandle + 1).ToString();
}
}
调用:
DrawRowIndicator(gridView1, 30);
备注:
显示行号可以直接给GridView添加CustomRowIndicator事件 ,即上面的“行号设置”方法
© Copyright 2014 - 2024 柏港建站平台 ejk5.com. 渝ICP备16000791号-4