Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get RowHandle (when it becomes valid) of new row of the grid (devexpress)

I have a grid, when user adds new row and is editting it, i want to pop-up a Save/Discard current chanegs option message when he tries to shift focus to another row.

Problem is I am unable to get handle of new row, so that i could do if prevFocusHanlde == newRowHandle && editModeOn

I only have the -214... as newrow handle which is default, but after row validation, grid geenrates a new valid rowhandle for this new row. Where to record that ? Tried doing in RowUpdated, but it doesnt get called and by that time handle hasnt updated.

like image 820
Munish Goyal Avatar asked Dec 03 '25 18:12

Munish Goyal


2 Answers

When an end-user starts to edit the new item row/card, the ColumnView.InitNewRow event is raised. You can handle this event to initialize particular fields within the new record. Once focus has moved to another row, the newly added row is added to the datasource and a blank new item row is displayed. The ValidateRow event is raised when a modified row is about to lose focus. Handle this event to specify whether row data is valid, and whether focus movement is allowed (you can use the ColumnView.IsNewItemRow method to determine whether the specified row is the New Item Row). Immediately after the row was added, its handle is equal to BaseView.DataRowCount - 1.

Related topics:

  • New Item Row Overview
  • Identifying Rows and Cards
  • Adding and Deleting Records
  • Validating Rows
like image 199
DmitryG Avatar answered Dec 06 '25 07:12

DmitryG


Whatever I understand from question you want to do something like below:

List<int> rowIndex = new List<int>();
private void dataGridView1_RowLeave(object sender, DataGridViewCellEventArgs e)
{
    if (!rowIndex.Contains(e.RowIndex))
    {
          rowIndex.Add(e.RowIndex);
          MessageBox.Show("Are you want to save changes?", "Save Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    }            
}
like image 21
Priyank Avatar answered Dec 06 '25 08:12

Priyank



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!