i want to resize a grid control based upon the number of rows in it (it is part of a splitter control and i want the splitter to move when rows are added.)
i can find out the size of all the rows with the RowSizes property, and this works just fine.
BUT.. heres the problem
It is a databound control fed with a DataTable. if i change the data source to add a row then the grid correctly displays the new data. Thats just fine...
what i want to do is detect that a row has been added. now the datatable gives me events to do this so i tried that. unfortunately though this RowAdded event is getting to my code BEFORE the values in RowSizes reflects the new data. so i thought - ok - i''ll call Application.DoEvents() and that''ll force the grid to update itself. unfortunately this doesnt work either. its as if the datagrid isnt drawing until much later.
i thought i could use the
Model.DataChanged, Model.ConfirmingPendingChanges or Model.RowsInserted events on the datatable to detect changes. however these events dont seem to get raised for changes made from a datatable changing
i''m stuck right now. any bright ideas? my best thought is to start a timer when new rows are added and then do my refresh.
ADAdministrator Syncfusion Team January 17, 2004 01:40 AM
The ListChanged event on the IBindingList object associated with the CurrencyManager for your datasource fires after the row is added.
''subscribe to the event
Dim cm As CurrencyManager = Me.BindingContext(Me.GridDataBoundGrid1.DataSource, Me.GridDataBoundGrid1.DataMember)
Dim ibl As IBindingList = cm.List
AddHandler ibl.ListChanged, AddressOf ibl_ListChanged
Private Sub ibl_ListChanged(ByVal sender As Object, ByVal e As ListChangedEventArgs)
If e.ListChangedType = ListChangedType.ItemAdded Then
ADAdministrator Syncfusion Team January 17, 2004 01:45 AM
Here is some C# code.
//subscribe to the event
CurrencyManager cm = (CurrencyManager) this.BindingContext[this.gridDataBoundGrid1.DataSource, this.gridDataBoundGrid1.DataMember];
IBindingList ibl = cm.List as IBindingList;
if(ibl != null)
ibl.ListChanged += new ListChangedEventHandler(ibl_ListChanged);
private void ibl_ListChanged(object sender, ListChangedEventArgs e)
if (e.ListChangedType == ListChangedType.ItemAdded)