彩票走势图

DevExpress XtraGrid自定义焦点行的方法

原创|其它|编辑:郝浩|2012-01-12 03:05:53.000|阅读 5816 次

概述:本文主要介绍DevExpress XtraGrid自定义焦点行的方法,希望对大家有帮助。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

自定义焦点行的方法:

gridView_bcode.FocusedRowHandle = focuseRowInt;

//通过设置GridView 的FocusedRowHandle属性

view plaincopy to clipboardprint?

//获取焦点行任意单元格的数据

ColumnView cv = (ColumnView)gridControl_Gongzi.FocusedView;

//重新获取此ID 否则无法从表头连删获取不到id

int focusedhandle = cv.FocusedRowHandle;

object rowIdObj = gridView1.GetRowCellValue(focusedhandle, "id");

if (DBNull.Value != rowIdObj)

{

FocusedRow_id = Convert.ToInt32(rowIdObj);

}

//获取焦点行任意单元格的数据

ColumnView cv = (ColumnView)gridControl_Gongzi.FocusedView;

//重新获取此ID 否则无法从表头连删获取不到id

int focusedhandle = cv.FocusedRowHandle;

object rowIdObj = gridView1.GetRowCellValue(focusedhandle, "id");

if (DBNull.Value != rowIdObj)

{

FocusedRow_id = Convert.ToInt32(rowIdObj);

}

view plaincopy to clipboardprint?

//当数据发生变化时执行

private void gridView1_CellValueChanged

(object sender, CellValueChangedEventArgs e)

{

int intRowHandle = e.RowHandle;

FocusedRow_bumen =

Convert.ToString(gridView1.GetRowCellValue(intRowHandle, "bumen"));

FocusedRow_xingming =

Convert.ToString(gridView1.GetRowCellValue(intRowHandle, "xingming"));

//FocusedRow_jibengongzi =

Convert.ToDecimal(gridView1.GetRowCellValue(intRowHandle, "jibengongzi"));

object rowJibengongziObj =

gridView1.GetRowCellValue(intRowHandle, "jibengongzi");

if (DBNull.Value != rowJibengongziObj)

{

FocusedRow_jibengongzi =

Convert.ToDecimal(rowJibengongziObj);

}

}

//当数据发生变化时执行

private void gridView1_CellValueChanged

(object sender, CellValueChangedEventArgs e)

{

int intRowHandle = e.RowHandle;

FocusedRow_bumen =

Convert.ToString(gridView1.GetRowCellValue(intRowHandle, "bumen"));

FocusedRow_xingming =

Convert.ToString(gridView1.GetRowCellValue(intRowHandle, "xingming"));

//FocusedRow_jibengongzi =

Convert.ToDecimal(gridView1.GetRowCellValue(intRowHandle, "jibengongzi"));

object rowJibengongziObj =

gridView1.GetRowCellValue(intRowHandle, "jibengongzi");

if (DBNull.Value != rowJibengongziObj)

{

FocusedRow_jibengongzi =

Convert.ToDecimal(rowJibengongziObj);

}

} view plaincopy to clipboardprint?

//设置焦点行的焦点单元格的位置

ColumnView view =

(ColumnView)gridControl_Gongzi.FocusedView;

view.FocusedColumn =

view.Columns["bumen"];

//设置焦点行的焦点单元格的位置

ColumnView view =

(ColumnView)gridControl_Gongzi.FocusedView;

view.FocusedColumn =

view.Columns["bumen"]; view plaincopy to clipboardprint?

//当焦点行发生改变时执行 获取选中焦点行id

private void gridView1_FocusedRowChanged

(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)

{

int intRowHandle = e.FocusedRowHandle;

 

object rowIdObj = gridView1.GetRowCellValue(intRowHandle, "id");

 

if (DBNull.Value != rowIdObj)//做个判断否则获取不到id后报错

{

FocusedRow_id = Convert.ToInt32(rowIdObj);

}

}

//当焦点行发生改变时执行 获取选中焦点行id

private void gridView1_FocusedRowChanged

(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)

{

int intRowHandle = e.FocusedRowHandle;

 

object rowIdObj = gridView1.GetRowCellValue(intRowHandle, "id");

 

if (DBNull.Value != rowIdObj)//做个判断否则获取不到id后报错

{

FocusedRow_id = Convert.ToInt32(rowIdObj);

}

}

 

view plaincopy to clipboardprint?

//焦点行的FocusedHandle为:

FocuseRow_Handle = -999998;

//获取焦点行的handle

ColumnView newview = (ColumnView)gridControl_Gongzi.FocusedView;

 

FocuseRow_Handle = newview.FocusedRowHandle;

//回车添加新行

private void gridView1_KeyPress(object sender, KeyPressEventArgs e)

 

{

if (e.KeyChar == 13)

{

ColumnView view = (ColumnView)gridControl_Gongzi.FocusedView;

if(view.IsLastRow)

{

if (FocuseRow_Handle == 0)

{

gridView1.AddNewRow();

 

ColumnView newview = (ColumnView)gridControl_Gongzi.FocusedView;

 

newview.FocusedColumn = newview.Columns["bumen"];//定位焦点网格的位置

 

FocuseRow_Handle = newview.FocusedRowHandle;

//获取新焦点行的FocuseRowHandle 并初始化全局变量FocuseRow_Handle供保存操作时判断是update还是insert

}


(慧都控件网版权所有,转载请注明出处,否则追究法律责任)



标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn

文章转载自:网络转载

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP