Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
685
moving off the line or moving to next cell in grid
posted

When i hit the save icon on a form  the subsequent "dsModified" does not see the changed records.
I need to either move to the next line on the grid before saving, or to the next grid field, depending.

ie.  I have some grids1,2,3,4 on a form and each uses a dataview.
Grids 1 and 2 share the same source - so here i need to move to the next line
and for grids 3 + 4 i need to move to the next field.

I have code to try to fix the gotcha.

in the save routine i have this ......

             //////////////// clear 
                if (this.bEATimeSheetEntryTypeDataGridView.ActiveRow != null)
                {
                    this.bEATimeSheetEntryTypeDataGridView.ActiveRow.Selected = false;
                }
                //////////////////  record
                this.bEATimeSheetEntryTypeDataGridView.Select();
                if (this.bEATimeSheetEntryTypeDataGridView.ActiveRow != null)
                {
                    storeposition1 = this.bEATimeSheetEntryTypeDataGridView.ActiveRow.Index;
                }
                ////////////////   churn it
                this.bEATimeSheetEntryTypeDataGridView.Select();
                if (this.bEATimeSheetEntryTypeDataGridView.Rows.Count > 0)
                {
                    if (this.bEATimeSheetEntryTypeDataGridView.Rows.Count > 1)
                    {
                        this.bEATimeSheetEntryTypeDataGridView.Rows[0].Activate();
                        this.bEATimeSheetEntryTypeDataGridView.Rows[1].Activate();
                        this.bEATimeSheetEntryTypeDataGridView.Rows[0].Activate();
                    }
                    else
                    {
                        this.bEATimeSheetEntryTypeDataGridView.Rows[0].Activate();
                    }
                }
                ///////////////// restore it
                this.bEATimeSheetEntryTypeDataGridView.Select();
                if (this.bEATimeSheetEntryTypeDataGridView.ActiveRow != null)
                {

                    this.bEATimeSheetEntryTypeDataGridView.Rows.GetRowWithListIndex(storeposition1).Activate(); //
                    this.bEATimeSheetEntryTypeDataGridView.ActiveRow.Selected = true;
                }

 

But it is all kinda messy.
Is there a neat way to overcome the problem?
Also if there is only 1 line in the grid, it does not work because you cannot move off the line.

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    My guess is that your Save button is a toolbar button or some other type of button that does not take focus. Since the grid is not losing focus when you click this button, the grid doesn't know to update the current row. 

    This is easily fixed. You can call Update on a row to update that single row (in this case probably the ActiveRow). Or you can call UpdateData on the grid to update all rows. 

Children
No Data