How to enable editing for new inserted row in a GridView while gridview is allowedit = false?
devexpress, gridview, winforms, xtragrid
Solution
I hope I understood your question. A few simple ways of doing this:
Adding a repository item to each column and handle the `ShowingEditor` event, using `e.Cancel` if this is supposed to be read only.
Popping up a window/textboxes, letting the user insert values and add the row with values already inserted via code.
assigning two different repository items to the same column using `gridView.CustomRowCellEdit` event. like such:
RepositoryItemTextEdit rep = new RepositoryItemTextEdit();
RepositoryItemTextEdit noRep = new RepositoryItemTextEdit();
noRep.ReadOnly = true;
private void button1_Click(object sender, EventArgs e)
{
gridView1.AddNewRow();
justAddedName = true;
gridView1.RefreshData();
}
private void gridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
{
if (e.Column == colname)
{
if (e.RowHandle == gridView1.RowCount - 1 && justAddedName)
{
e.RepositoryItem = rep;
}
else
{
e.RepositoryItem = noRep;
}
}
}
It's not complete, just a direction to explore.
Hope I helped.
Problem
I have a GridView control of xtraGrid suite in a form. When I open the form for first time it is AllowEdit = false. I want that when I press on add new row link(built in by control) to make editable this only new inserted row. I read that I should use ShowingEditor event but I don't know how. I wrote this so far but this does not editable the row: ``` private void gridViewNote_ShowingEditor(object sender, System.ComponentModel.CancelEventArgs e) { //this is first tryout //if (gridViewNote.IsNewItemRow(gridViewNote.FocusedRowHandle))// == gridViewNote.GetFocusedDataRow()) //{ // gridColumnStagione.OptionsColumn.AllowEdit = true; //} //second tryout GridView view = sender as GridView; SchedeMaterialiDaTaglioDS.SMTAGL_NOTERow currentRow = gridViewNote.GetFocusedDataRow() as SchedeMaterialiDaTaglioDS.SMTAGL_NOTERow; SchedeMaterialiDaTaglioDS.SMTAGL_NOTEDataTable changesTable = dsSchMatTaglio.SMTAGL_NOTE.GetChanges() as SchedeMaterialiDaTaglioDS.SMTAGL_NOTEDataTable; e.Cancel = !view.IsNewItemRow(view.FocusedRowHandle) && !changesTable.Contains(currentRow);// set.Inserts.Contains(order); } ```