views:

299

answers:

2

I am using a datagridview for which i am not using any datasource. I want to dynamically allocate values to it. Create my own selected number of columns and rows and name them. Plus i want to add images to cells instead of data .

as for changing columns text we can use

grid.Columns[0].HeaderText = "Frist Column";

how to change use it for labeling rows

+1  A: 

Set the HeaderCell.Value for the row:

    DataGridView dgv = new DataGridView();
    dgv.Columns.Add("Foo", "Foo Text");
    dgv.Rows.Add();
    dgv.Rows[0].HeaderCell.Value = "Row Text";

    Form form = new Form();
    form.Controls.Add(dgv);
    Application.Run(form);
Marc Gravell
its good but how to use images in cells instead of strings?Plz help
Mobin
That I don't know...
Marc Gravell
There is an example here that shows using CellPainting for this; I haven't tested it, though: http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/17a65aed-8796-408e-98e4-92a82999df13
Marc Gravell
A: 

We can use to change the column number by

dataGridView1.ColumnCount = 10;

:D

Mobin