Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
21033 | Nov 1,2004 05:40 AM UTC | Nov 5,2004 05:28 AM UTC | WinForms | 14 |
![]() |
Tags: GridControl |
if(!grid.Binder.IsAddNew)
check around the code in that handler to avoid hitting it for the AddNew row as the AddNew row is really not sent back to teh DataSource until you leave it.
int col = this.grid.CurrentCell.ColIndex;
int field = this.grid.Binder.ColIndexToField(col);
string colName = this.grid.GridBoundColumns[field].MappingName;
3) It depend on exactly where/when you want to cancel the addnew. If you are doing it from the grid.RowLeave event, you can use code like:
private void gridDataBoundGrid1_RowLeave(object sender, GridRowEventArgs e) { if(this.gridDataBoundGrid1.Binder.IsAddNew) { //if you want to cancel the addnew this.gridDataBoundGrid1.CurrentCell.CancelEdit(); this.gridDataBoundGrid1.Binder.CancelEdit(); } }
private void button1_Click(object sender, System.EventArgs e) { if(this.gridDataBoundGrid1.Binder.IsAddNew) { this.gridDataBoundGrid1.Focus(); this.gridDataBoundGrid1.CurrentCell.EndEdit(); this.gridDataBoundGrid1.Binder.CancelEdit(); } }
private void gridDataBoundGrid1_RowSaved(object sender, GridRowEventArgs e) { if(e.RowIndex == this.gridDataBoundGrid1.Model.RowCount-1) this.dataset11.Tables["B_Gruppi"].Rows[e.RowIndex-1]["LivelloID"] = 0; }
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.