Adding items to datagrid at runtime
I have a system.windows.forms.form with a datagrid in it. in the load method i bind a dataTable into it.
and i have a method that in runtime adds some items to the dataTable after an event. i did the following:
DataTable dataTable =(DataTable)dataGrid.dataSourse;
DataRow dataRow = dataTable.newRow();
dataRow[0] = "some string";
dataRow[1] = "another string";
dataTable.Rows.Add(dataRow);
it works, but when there are more than 10 items (the max display without a scrollBar), the scrollBar is added.
sometimes it's stuck, and if not, when adding a new item there are two scrollBars, and other freak things.
When adding items "slowly" it doesn't always do that, it happens when adding 4-5 items one after another.
Thanks in advance,
Hisham
|