Skip to main content

Microsoft Silverlight

Silverlight 3.0 Datagrid issueRSS Feed

(0)

swathywilson
swathywi...

Member

Member

0 points

1 Posts

Silverlight 3.0 Datagrid issue

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
Ardman

Contributor

Contributor

3344 points

926 Posts

Re: Silverlight 3.0 Datagrid issue

Have you bound the DataGrid to data before doing so?

RyanFerg
RyanFerg

Member

Member

7 points

5 Posts

Re: Silverlight 3.0 Datagrid issue

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

If this post has helped you, please click "Mark as answer".

Min-Hong Tang - MSFT
Min-Hong...

Contributor

Contributor

3375 points

377 Posts

Re: Silverlight 3.0 Datagrid issue

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

Min-Hong Tang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities