Select added item and expand it's group

3 posts, 0 answers
  1. Trude
    Trude avatar
    222 posts
    Member since:
    Jun 2009

    Posted 28 Nov 2012 Link to this post

    I have a gridview with a group defined like so:
    Dim group As New GroupDescriptor With {.Member = "name"}
    group.AggregateFunctions.Add(New CountFunction With {.ResultFormatString = "({0:d})"})
    GridView1.GroupDescriptors.Add(_group)

    This code is executed each time the datacontext changes and the oldvalue is null (groupdescriptors are removed when datacontext is null)

    If I add an item to the source a group is formed and the item is placed there. So far so good, but I want the code to expand the newly formed group and select/highlight the newly added item. What's the best approach? I have tried the gridview's grouped event, but that does not fire. I have tried the itemcontainergenerator, but the added grouping row does not seem to fire anything?
  2. Trude
    Trude avatar
    222 posts
    Member since:
    Jun 2009

    Posted 28 Nov 2012 Link to this post

    Seems like I can use ScrollIntoView or ScrollIntoViewAsync, but I can't get the grid to focus on the added item by setting SelectedItem/CurrentItem?
  3. Trude
    Trude avatar
    222 posts
    Member since:
    Jun 2009

    Posted 29 Nov 2012 Link to this post

    I solved this problem by using this call - it expands the group, scrolls into view and selects the item - perfect!

    GridView1.ScrollIntoViewAsync(item, _
        Sub(f)
            GridView1.Focus()
            GridView1.SelectedItem = item
            GridView1.CurrentItem = item
        End Sub)
Back to Top