I have a grid bound to a class that implements the IBindingList interface.
If I put the cursor on a cell of the add new row...it instantly tells the bound class to add a new row...even if I dont enter any data...
I end up saving new empty rows...
Simple enough to clean them out when saving the data by sniffing the empty rows and dumping them...
Would be better to be able to supress the binding update unless or until there is actual data put in the cell...
Of course the grid needs the new row to actually be able to type into it so to speak...but is there anyway to make the grid clean up after itself if the user does not enter data in the cell.
Any suggestions?
CW
The ListObject property of your grid row represents its underlying data object.
Well I am not sure what I did but its working pretty much as expected now...I have the overides set thus: TemplateOnTopWithTabRepeat, allow Delete True, allow Update true....and its working right...
One more question:
So I have this grid bound up with a IBindingList...
How I can get a reference to the objects in my list from the grid...
Lets say I am sniffing for the before row delete....that has a row[ array in its event args...
How can I can reference back to the underlying object in my list given the row?
In other words...how can I look at a row in the grid...and then worm my way to the object in my list?
Hi CW,
What version of the grid are you using?
If you click into the TemplateAddRow and do not change anything, then leave that row, the row should be cancelled. The row should only be committed and created in the data source if something has changed.
If that's not happening, then something is wrong. Try the same thing with a DataTable, instead of your IBindingList. If that works correctly, then it means something is wrong with your IBindingList implementation. If it does not, it indicates a problem in the grid. Maybe you need to get the latest Hot Fix.
It's possible to force the TemplateAddRow to behave as though it were modified by the user even when it is not. So perhaps your code is doing this. Check to see if your code is setting AddRowModifiedByUser to true anywhere.
Arun's tip didnt work....and neither did yours...
So lets go back to the original question....
When you have the grid set to add new rows...and you have your gray edit row....and you drop the cursor on a cell of it...the edit cursor blinks in the cell...
Here is the key...until you start typing you don't actually get the new row that drops down in the GUI/Grid...your just sitiing there with your with the edit cursor blinking in the gray row...
So if you do nothing and bail out...and come back in...their is new empty row saved..by merley placing the cursor in the gray add row it calls the underlyer to add a new element....
If you type somthing then we get that new drop down row in the grid...the grid does this....visually you dont get a new row in the GUI until you type somthing.....
What I want is to stop the grid from adding a new row unless or until that new grid GUI row drops into the mix...the one the grid produces the moment you start typing...In other words...I want the grid to tell the source to add a row ONLY IF I TYPE SOMTHING...I only want the gird to tell the source to ADD a row when it ADD'S a ROW...
Seems pretty obvious that the grid should do this...What am I missing?
What event is that?
Mike Saltzman"]In order for the grid to display an AddNew row, there has to be a row in the underlying data source. So there is no way to prevent the grid from asking the BindingManager to add a new row. What you probably need to do here is implement IEditableObject. This is the interface that most data source, such as the DataTable, use to allow the creation and cancellation of new rows.
In order for the grid to display an AddNew row, there has to be a row in the underlying data source. So there is no way to prevent the grid from asking the BindingManager to add a new row.
What you probably need to do here is implement IEditableObject. This is the interface that most data source, such as the DataTable, use to allow the creation and cancellation of new rows.
He he...down the rabbit hole we go...another interface to fold not so seamlessly at first into my app...
Thanks to both of you...