Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Select a row in DataGrid RSS

6 replies

Last post Feb 19, 2011 07:28 PM by Rakhi Garg

(0)
  • GearWorld

    GearWorld

    Participant

    1661 Points

    2024 Posts

    Select a row in DataGrid

    Nov 26, 2008 06:42 PM | LINK

    When I use the DataGrid ScrollView it does what it does but I'm unable to scroll to the end to see the last row of the DataGrid. 
    Is it a BUG or its me not knowing how to do that ?

     
    dgWorkedOn.SelectedIndex = dgWorkedOn.ItemsSource.OfType(ProxyCode.ProjectWorkedOn).ToList().Count - 1;
    dgWorkedOn.ScrollIntoView(dgWorkedOn.SelectedItem, dgWorkedOn.Columns[0]);
    
     
    I get INVALID ROW INDEX

    I've debugged and the SelectedIndex is right and the SelectedItem is right so what is not right on this to get the errur above ?

     

     

     

  • Ken Tucker

    Ken Tucker

    All-Star

    23246 Points

    3532 Posts

    Re: Select a row in DataGrid

    Nov 27, 2008 01:04 AM | LINK

     

            dgCustomers.ItemsSource = d
            dgCustomers.ScrollIntoView(d(d.Count - 1), dgCustomers.Columns(0))
            dgCustomers.SelectedItem = d(d.Count - 1)
    
     

  • GearWorld

    GearWorld

    Participant

    1661 Points

    2024 Posts

    Re: Select a row in DataGrid

    Nov 27, 2008 12:53 PM | LINK

    I still get Invalid Row Index

    But d is really good...  I don't get it

  • Ken Tucker

    Ken Tucker

    All-Star

    23246 Points

    3532 Posts

    Re: Select a row in DataGrid

    Nov 27, 2008 02:20 PM | LINK

    d is an ObservableCollection filled with data that came from an ado.net data service
  • GearWorld

    GearWorld

    Participant

    1661 Points

    2024 Posts

    Re: Select a row in DataGrid

    Nov 27, 2008 11:08 PM | LINK

    Yeah even if it's not the same as me, the result should be the same as for selecting the last row and scrolling to that row yet, I always get Invalid Row Index

    If you don't get it, other people are reporting that it bounds up 1 row. there's definitely something wrong

     

  • Amanda Wang - MSFT

    Amanda Wang...

    All-Star

    17236 Points

    1466 Posts

    Microsoft

    Re: Select a row in DataGrid

    Dec 03, 2008 07:21 AM | LINK

     Hi GearWorld,

    You also post this question here :  http://silverlight.net/forums/t/53570.aspx. and we have replied  you in that thread. If you have any question, please follow our reply.

    Amanda Wang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Rakhi Garg

    Rakhi Garg

    Member

    53 Points

    30 Posts

    Re: Select a row in DataGrid

    Feb 19, 2011 07:28 PM | LINK

    Hi,

    I set SelectedItem in grid but selected item row is not highlighted at load.

    I set in DataGridRow Style. It works but after MouseClick on Row.

    I want full row selection at load. I set itemssource as observablecollection.

    Please tell me how can i do this ?