Setting the Row Header of a Datagrid through the rows of a Datatable column using C# WPF

Asked

Viewed 125 times

0

I have a Datatable with the following information :

Column1 | Column2

1    |   A
2    |   B
3    |   C
4    |   D

With this Datatable I would like to load a Datagrid using the first column of Datatable to be the Row Header, thus

  A    B   C   D

1

2

3

4

Just put the Coluna2(At the top) I managed one way, passing the data from Datatable1 to Datatable2 and thus being able to load it to Datagrid as follows:

where Dtgrade is Datatable receiving the top column

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        dtGrade.Columns.Add(dt.Rows[i][1].ToString());
                    }

                    gvDados.ItemsSource = null;
                    gvDados.ItemsSource = dtGrade.DefaultView;

Now I would like to add the columns on the left side.

  • I don’t understand. Please edit the question making it clearer. If possible explain what you really want to do, that only with ABC, 123, is vague, at least for me.

  • Murilo, the idea of this grid is as follows: I have a clothing sales system where different sizes and colors have different values, different barcodes ... the idea of setting up this grid and to make more evident the list of products already registered. For example I have a column: size and other color ... so various colors can have various sizes, I wanted to make this grid so that when I clicked on a cell that was the cross of the items could visualize the product, for example size p, black color, size m blue color ... what do you think to do like this? I’m open

  • a Suggestions, would have a better way to do this?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.