本文主要是介绍查询结果添加序号,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
this.gridView1.CustomDrawRowIndicator += gridView1_CustomDrawRowIndicator;
/// <summary>
/// 序号
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
{
//第一种方式
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
{
e.Info.DisplayText = (e.RowHandle + 1).ToString();
}
}
//第二种方式
if (e != null && e.Info.IsRowIndicator && sender != null)
{
e.Info.DisplayText = (e.RowHandle + 1).ToString();
e.Info.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
//选中行时判断行右边带三角号
if (e.RowHandle == (sender as GridView).FocusedRowHandle)
{
//带
e.Info.ImageIndex = 0;
}
else
{
//不带
e.Info.ImageIndex = -1;
}
}
这篇关于查询结果添加序号的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!