Hi
I using UltraWinGrid in my VB.NET windows application. I have two unbound columns in my Grid.
I have written code in Grid_InitializeLayout event to add unbound columns.
I want to set values in the unbound columns based on the values in the others cells of every row.
I have used Grid_Initializerow event to do this. This event is fired when i set the Datasource to the grid and the values are set in the unbound cells as per the condition given.
But this event is fired again when i change the values in the unbound columns and the values are set again.
Can i prevent the Initializerow event from firing when user edits the unbound columns?
What is the best way to bind values to unbound columns based on the values in the other cells?
Ashok
Thanks Mike. That helps.
Hi Reddy,
It sounds like you should be checking inside the InitializeRow event for e.ReInitialize and only do your computations when it's false. That way it will only happen the first time the event fires on each row.
If you need to update the data later and want to do it all at once, then you can call BeginUpdate on the grid, change all the values you want, then call EndUpdate. I think InitializeRow will fire for all the rows that needed it at that point. But I may be wrong about that. If I am, then you can call grid.Rows.Refresh(FireInitializeRow) to force it to fire.
Hi,
I have two related questions on the same topic. How can I set the values to unbound columns without firing initilizerow event. or How can I force a row to get into initializerow event.
My problem is that I have a grid with 20 unbound columns and I have a time intensive functions which compute values for these columns. initializeRow event is fired for the first time the rows are displayed. so far so good. But, after the grid is displayed then also I have to compute values for these columns depending on my business class events. But, then when I set a value to these unbound columns, Initilizerow event is fired again resulting in unnecessary computation. I want to compute values only once. Therefore, I am looking for a possiblity to set the values for unbound columns by suppressing the INITIALIZEROW event or It is also fine, if I can select certain rows and mark them for intializerow event when I show the grid next time.
Thanks,
reddy.
So check e.Row.Cells.Exists("column name") inside InitializeRow before you try to set the value on the cell.
Hi Mike
I am adding unbound columns in Grid_InitializeLayout event. When i assign the datasource to the Ultragrid, Grid_InitializeRow event is fired first and then it goes to Grid_InitializeLayout.
So in Grid_InitializeRow event When i access the unbound cell using column key it gives an error "Key not found"
Grid_InitializeRow is also fired when i change the values in the cell and causing problems.
Is there any other work around to bind values to Unbound columns(only when datasource is assigned to Grid) based on the values in other cells of the row??