Hi,
I'm creating a simple UI for a small program and have some issues.
- I wish to use te NewItemRow for quick inserts.
- I wanted the user to be able to double click any of the rows in the grid to open up an edit window. To accomplish this i have to make the grid read-only thus the NewItemRow dont work.
Instead, i've added a column with a imagecombobox lookup and added some buttons that i handle when clicked. I do not wish these to be visible in the NewItemRow, and tried overriding the ShowingEditor event, but this only solves the problem halfways. It is still visible when the column has focus.
Can I accomplish this any way?
Hi Stefan,
We suggest that you try the approach provided in the How to hide a check box in a grid cell article.
Please let us know if this solution meets tour requirements.
Thanks,
Michael.
Thank you,
The following code solved my problem.
private void gvLog_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) { if (e.Column.Name.Equals("colRowButtons") && gvLog.IsNewItemRow(e.RowHandle)) { e.Appearance.FillRectangle(e.Cache, e.Bounds); e.Handled = true; } } private void gvLog_ShowingEditor(object sender, CancelEventArgs e) { DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView; if (!view.IsNewItemRow(view.FocusedRowHandle)) return; if (view.FocusedColumn.Name.Equals("colRowButtons")) e.Cancel = true; }
Do you have an answer for the scenario described in the previous post? About being able to double-click the rows and still use the NewItemRow?
Also, which event do handle to process new rows added with the NewItemRow row? I wish a window to open so that the user can apply more info than is showing in the grid after he has saved the row.
Hi Stefan,
To implement row editing in a separate form invoked on row double-click, please try the solution used in the GridEditDataInPopupForm module of the GridTutorials project shipped with the suite.
I'm afraid it is impossible to designate rows just added to the grid via the NewItemRow from others. When a row is updated, or added to a datasource, the GridView.RowUpdated event fires. You can handle this event, and check if the row property that isn't listed in grid columns isn't initialized, and show the popup form.
I'm looking forward to hearing from you.
Thanks,
Michael.
Hi Michael,
The code sample implies double-clicking on the row-indicator OR in a row if the grid is set to read only. The problem however is being able to use the NewItemRow if it's read-only.
In the RowUpdated event i checked if the RowHandle was < 0 since the IsNewItemRow function does not return true. I think this solution is correct.
Hi Stefan,
To disable editing all rows except the NewItemRow, make the view editable, and handle the GridView.ShowingEditor event in the following way:
void gridView1_ShowingEditor(object sender, CancelEventArgs e)
{
GridView view = sender as GridView;
if (!view.IsNewItemRow(view.FocusedRowHandle))
e.Cancel = true;
}
As for checking the RowHandle<0 condition in the RowUpdated event, the NewItemRow handle will never be passed, because when a row is updated it gains a normal handle. We still recommend that you use a special field for this purpose, which can be initialized only in a popup form.
Thanks,
Michael.