Skip to main content
Home Forums Silverlight Programming Report a Silverlight Bug Silverlight 3.0 Datagrid issue
3 replies. Latest Post by Min-Hong Tang - MSFT on October 27, 2009.
(0)
swathywi...
Member
0 points
1 Posts
10-22-2009 8:09 AM |
Hi
If you clear all the columns of the datagrid and try to add columns to the grid again, out of bounds error is thrown.
datagrid.columns.clear();
datagrid.columns.add(new datagridtextboxcolumn())
Ardman
Contributor
3344 points
926 Posts
10-22-2009 8:41 AM |
Have you bound the DataGrid to data before doing so?
RyanFerg
7 points
5 Posts
10-22-2009 11:24 AM |
I was having Out Of Bounds exceptions thrown while trying to access silverlight 3 datagrid.columns collection (it had been working in Silverlight 2). You can look at the thread on my issue for a couple things I noticed about this problem. http://forums.silverlight.net/forums/t/137050.aspx Ryan
Min-Hong...
3375 points
377 Posts
10-27-2009 11:17 PM |
Hi,
I reproduced your situation and nothing went wrong as long as i set the binding of my DataGridTextColumn. But the error message i get is different with yours. So i can just suggest you to set your Column's binding first. If you can provide more of your code block or desribe your situation more specificly so that i can repro your program more accurately i will be very appreciated.
Anyway this is how my code block of doing so.
private void btn_Click(object sender, RoutedEventArgs e) { mygrid.Columns.Clear(); DataGridTextColumn tc = new DataGridTextColumn(); tc.Binding = new Binding("Age"); mygrid.Columns.Add(tc); }
Best Regards