Home Forums WPF controls Xceed DataGrid for WPF C# adding grouping

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #25029 |

    Hi,

    I would like to use DataGrid just to display some data in a grid. The data is dynamically filled in using C# since the data needs to be refreshed with every click on “refresh” button. This part works with no problems so far 🙂

    When I add grouping using the “GroupDescriptions” method the top row displays the data is grouped, but the debug windows from visual studio says that it has some invalid rows and all the data is grouped in just one group.

    If I don’t use GroupDescriptions from C# but using mouse (drag & drop) everything works just as expected, but I would preffer to have it displayed for users.

    C# source code:
    ——————-
    grid.Items.Clear();

    OleDbDataAdapter myAdapter = new OleDbDataAdapter(“SELECT active.id, ” AS act_active, group AS act_group, act_type AS akt_type, 10 AS act_duration, 5 AS act_calories, 15 AS act_total FROM activity;”, this.db);
    DataSet oDataSet = new DataSet();
    myAdapter.Fill(oDataSet, “activity”);
    DataGridCollectionView view = new DataGridCollectionView(oDataSet.Tables[“activity”].DefaultView);

    grid.ItemsSource = view;
    grid.Items.GroupDescriptions.Add(new PropertyGroupDescription(“act_group”));

    My XAML looks like:
    ———————–
    <!– The read-only main DataGridControl. –>
    <xcdg:DataGridControl x:Name=”dnevne_aktivnosti_tbl2″
    CellEditorDisplayConditions=”None”
    EditTriggers=”None”
    HideSelection=”False”
    ReadOnly=”True”
    SelectionMode=”Single”>

    <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName=”id”
    Visible=”False”
    />
    <xcdg:Column FieldName=”act_active”
    Visible=”False”
    />
    <xcdg:Column FieldName=”act_group”
    Title=”Group”
    />
    <xcdg:Column FieldName=”akt_type”
    Title=”Activity”
    />
    <xcdg:Column FieldName=”act_duration”
    Title=”Duration”
    />
    <xcdg:Column FieldName=”act_calories”
    Title=”Calories”
    />
    <xcdg:Column FieldName=”act_total”
    Title=”Total activity”
    />
    </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>

    Message from Visual studio:
    ——————————–
    System.Windows.Data Error: 35 : BindingExpression path error: ‘act_group’ property not found on ‘object’ ”DataRow’ (HashCode=34909671)’. null

    Do you have any ideas on what am I doing wrong?

    Thank you

    Imported from legacy forums. Posted by Martina (had 483 views)

    User (Old forums)
    Member
    Post count: 23064

    I solved it!

    C# used the wrong “DataGridGroupDescription”. C# used windows but instead I needed to use Xceed one:

    grid.Items.GroupDescriptions.Add(new Xceed.Wpf.DataGrid.DataGridGroupDescription(“act_group”));

    Hope this will help somenone 🙂

    Imported from legacy forums. Posted by Martina (had 233 views)

    User (Old forums)
    Member
    Post count: 23064

    It sure did!

    Thank you.

    Imported from legacy forums. Posted by Todd (had 3293 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.