1

I need to implement a user control with a datatable or something that you suggest for having different column length and it should be responsive. Every row in this table has at least 3 columns and there is no maximum value for column count. For instance, first row has 3 columns, second row has 5 columns, third row has 12 columns. However, I don't know the maximum column length for a single row. I thought that using data table is beneficial like

         DataTable dt = new DataTable();
            dt.Columns.Add("first column", typeof(string));
            dt.Columns.Add("second column", typeof(string));
            dt.Columns.Add("third column", typeof(List<string>));
            DataRow dr = dt.NewRow();
            dr[0] = "1";
            dr[1] = "a";
            dr[2] = new List<string>(){ "a","b","c","d"};
            dt.Rows.Add(dr);
            dr = dt.NewRow();
            dr[0] = "2";
            dr[1] = "c";
            dr[2] = new List<string>() { "a", "b", "c"};
            dt.Rows.Add(dr);
            dr = dt.NewRow();
            dr[0] = "3";
            dr[1] = "d";
            dr[2] = new List<string>() { "a", "b", "c","d","e" };
            dt.Rows.Add(dr);  
            gridControl1.DataSource = dt;

I used Devexpress GridView and I see below

this .

But I don't want to see like this. Is there any control that can represent this data like this ?

Thanks in advance !

gokberk
  • 9
  • 3
  • One possibility is to use a DataGridView with a single column whose values are the concatenation of list items (e.g. "a;b;c" or "a;b;c;d;d;f") and process the CellPainting event of the DataGridView to draw the strings and appropriate borders between them. – Graffito Dec 26 '16 at 10:47
  • Thanks for your reply. I thought your solution but a b c d or etc. should be also clickable. – gokberk Dec 26 '16 at 12:23
  • Use the CellMouseDown event of the DataGridView and deduce from e.X the logical Cell. When painting the "merged" cell or processing the Cell MouseDown event, use TextRenderer.Measure String() to adjust "logical" cells width or deduce the "clicked" item. – Graffito Dec 26 '16 at 21:31
  • May I use Treelist or is there anything like horizontal treelist ? – gokberk Dec 27 '16 at 10:05

1 Answers1

0

Grid view used to display tables and table have fixed row and column

Only you can add maximum number of column as column and this type presenting grid view is not possible in any grid view.

To display table like this you can only use HTML preview in your software or use draw to create image like this this is not grid view at all