I have created an UltraWinGrid which is binding to a datasource that holds a data table.I manually add columns to the Grid. (Ex. grid.DisplayLayout.Bands[0].Column[1]) and manually setting the property of all the columns in the grid.
I'm trying to add new row to the Grid and it succeeds only if I call immediately the save database command.
But, if I try to click any other row besides the "new row" the grid clears away all the details added to the new row.
How can I keep the focus to the new row till I save it? What are my options?
hi krish,
In Grid set ,
RowUpdateCancelAction = RetainDataAndActivation
and try playing with the BeforecellDeactivate event to check if it is a New AddRow and then validate it of force the user to keep him focused in the current cell
take care of the Update Mode - preferably to be on CellChangeot lostfocus
hope helps you out,
hppy Koding,
Arun
Thanks Arun.
I will try this out.
Thanks,
Krish.
Hi Krish,
I can't see what RowUpdateCancelAction could possibly have to do with this. It sounds to me like you are under a basic misconeption about the grid.
You say you are creating all of the columns in the grid yourself? How are you doing that? Are you doing this at design-time? Are you binding the grid to a data source after that?
The grid MUST be bound to a data source, it cannot be used unbound. So it sounds to me like you are trying to use it without a data source and that's why the data is just disappearing, because there is nothing to store it. If you want to use the grid without a database, then I recommend you using an UltraDataSource or perhaps a generic BindingList<> as your data source.
In theory..YES.
Okay, this code doesn't make any sense. The SetDataBinding method essentially sets the DataSource and DataMember properties of the grid. So calling SetDataBinding immediately after setting the DataSource is essentially setting the same property twice, and the second time you are setting it to itself.
In any case, setting the grid's DataSource ot the TestDataTable will automatically cause the grid to create a band and column structure based on the data source. If there are no columns in your grid after setting the DataSource, then the DataSource you are using must not haveany columns defined.
Well, I did not create the binding by using the UltraWinGrid Designer where as I issued the following commands to enforce binding. This process did not create any columns.
grdTest.DataSource = TestDataTable;
grdTest.SetDataBinding(grdTest.DataSource,null);
This is where you lose me:
krish_pn said:I'm creating all my columns at run time for the grid and displaying the values by issuing the database command.
If you bind the grid to a data source, it automatically creates all of the columns and bands the data source exposes. You cannot add or remove bound columns to the grid. So what columns are you creating at run-time?
Hi Mike,
Thanks for the Note.
Sorry! I think I did not described my original issue very well.
I have created a data table and I'm binding the grid to the datasource where the data table was assigned.
Some thing like this..
I'm creating all my columns at run time for the grid and displaying the values by issuing the database command.
I noticed this problem with the above condition. I'm not sure if I missed out anything.
BTW, I canceled this occurence by using RetainDataAndActivation firing at BeforeRowUpdate Event.