I have a Windows Forms datagrid with the datasource set to an ArrayList.
The ArrayList is initially empty.
I have DataGridColumn styles defined for 4 columns with widths, header
titles, and mapping names set.
The problems:
1: Now, I realize ArrayList doesn't implement IBindingList, so the
CurrencyManager won't get updated when I add items to the array.
I was under the impression I could simply do:
CurrencyManager cm = BindingContext[myDataGrid.DataSource] as
CurrencyManager;
cm.Refresh()
and that would fix it. Even though according to the watch window, I have 4
visible columns and 1 visible row after adding the row and calling
CurrencyManager.Refresh. Calling DataGrid.Refresh() does nothing for this
either.
The only solution I've found is to do something like:
grid.DataSource = null;
grid.DataSource = myArray;
But that seems stupid.
2: Column headers don't display unless there's data in the array. Is there
any way around this? I'd like them to display all the time because when
there's no data, it's just a big square empty control.
3: Using the code from George Shepard's Windows Forms FAQ, #5.11, I have the
grid set up so that clicking on a row selects the entire row on mouse up.
The problem is, when you press the mouse on a cell and don't let up, the
cell is selected. I tried duplicating the code in the MouseDown event, but
that doesn't work. Any ideas on how to fix that?
Thanks.
Pete