SelectRow seems to not work

from:
http://www.devexpress.com/Support/Center/p/B191028.aspx

Hi,

I have a Grid, on which a user can change certain fields, like on a right click they can increase a counter on the row by one (just changes a field by + 1, nothing else). Now when the user does this, the RowHandle seems to increment by 1. So if I was on row 0, it then goes to the second row in the grid (i.e. row handle 1). I've tried to write code to prevent this, by doing the following:

//From the right click event we get the row
var menuInfo = grdView.GridMenu.MenuInfo as GridCellMenuInfo;
var listIndex = grdDetail.GetRowListIndex(menuInfo.Row.RowHandle.Value);

... all the changing of stuff happens...

grdView.SelectRow(grdDetail.GetRowHandleByListIndex(listIndex));

(also tried with grdView.BeginSelection(); and grdView.EndSelection(); around this line, no change.)

But having debugged the code, everything looks fine, the listIndex is correct, and the GetRowHandleByListIndex returns the correct RowHandle, just just the SelectRow that seems to not be working as it should.

Or am I missing something?

Thanks.
<-     Reviewed by DevExpress Team         2010/9/15 12:44:09
<-     Processed (Can't Reproduce) by DevExpress Team         2010/9/15 13:09:44

Hi Richard,

Thank you for the report.

I'm afraid I do not quite understand under which conditions the situation you described occurs and how to reproduce it. However, I think I've found the cause of the problem. In fact, the SelectRow method works in MultiSelect mode only (please look at the Multiple Row Selection help topic to learn more). If that is not the case, you should manipulate the GridView's focused row instead. Please modify the code as follows:

[C#]
grdView.FocusedRowHandle = grdDetail.GetRowHandleByListIndex(listIndex);

If my guess is valid, this should help you address the issue.

Thanks,
Vito

转载于:https://www.cnblogs.com/luoyaoquan/archive/2011/08/02/2125335.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值