开发者

DevExpress XtraGrid MakeRowVisible

开发者 https://www.devze.com 2023-03-16 04:09 出处:网络
EDIT: The problem has something to do with when I am invoking the method.If I wait for the form to be displayed, and invoke the method from a menu on the form itself, it works. But if I set the row to

EDIT: The problem has something to do with when I am invoking the method. If I wait for the form to be displayed, and invoke the method from a menu on the form itself, it works. But if I set the row to be displayed before the form has finished rendering, it doesn't work. Does the XtraGrid raise an event when it has finished rendering?

I am not having any success with making a specific row in the grid visible using its row handle. I've tried both the MakeRowVisible method of the GridView and also simply setting the ColumnView's FocusedRowHandle property, both of which are supposed to bring the specified row into view.

Note: when focusing a row using the Col开发者_如何学运维umnView.FocusedRowHandle property, the View automatically makes the specified row visible on screen. The MakeRowVisible method is used for this purpose. So, you don't have to use the MakeRowVisible method if you need to focus the target row. Simply assign the desired row handle to the ColumnView.FocusedRowHandle property. http://documentation.devexpress.com/#WindowsForms/DevExpressXtraGridViewsGridGridView_MakeRowVisibletopic

I must be missing something basic. Thanks for the help.

 public void SetVisibleRow(int customerid)
        {

         DevExpress.XtraGrid.Views.Base.ColumnView  vw;
         vw = (DevExpress.XtraGrid.Views.Base.ColumnView) MyGrid.DefaultView;

          for ( int i = 0; i < vw.DataRowCount;  i++)
            {
                 if ((int)vw.GetRowCellValue(i, "custid") == customerid)      
                  {
                    // DevExpress.XtraGrid.Views.Grid.GridView gv;
                    // gv =  (DevExpress.XtraGrid.Views.Grid.GridView) MyGrid.DefaultView;
                    // gv.MakeRowVisible(i,false);

                    vw.FocusedRowHandle = i;
                    break;
                  }
            }

        }


If you are calling your SetVisibleRow method in the form's OnLoad event, make sure to call the grid control's ForceInitialize method first.


The problem is solved if the method is invoked in the grid's Load event.


        gridView.ClearSelection();
        gridView.SelectRow(rowHandle);
        gridView.FocusedRowHandle = rowHandle;
        gridView.TopRowIndex = rowHandle;
0

精彩评论

暂无评论...
验证码 换一张
取 消