DataGridView title text

S

Steve Richter

I set the Text of a DataGridView control expecting this text to be
displayed at the top of the control, as the grid title. But the text
does not display. How do I display title text above the column
heading of a DataGridView?

thanks,

DataGridView mGrid1 ;

mGrid1 = new DataGridView();
mGrid1.Parent = this;
mGrid1.AutoSize = true;
mGrid1.Dock = DockStyle.Fill;
mGrid1.ColumnCount = 0;
mGrid1.AutoGenerateColumns = false;
mGrid1.ColumnHeadersVisible = true;
mGrid1.RowHeadersVisible = false;
mGrid1.AllowUserToAddRows = false;
mGrid1.Text = "Finance Disbursements - 2007";

Grid_AddColumns(mGrid1);

private void Grid_AddColumns(DataGridView InGrid)
{
DataGridViewTextBoxCell tbCell = new DataGridViewTextBoxCell();
DataGridViewColumn tbCol = new DataGridViewColumn();
tbCol.Name = "CheckNbr";
tbCol.HeaderText = "Check number";
tbCol.CellTemplate = tbCell;
tbCol.Width = this.Font.Height * 12;
InGrid.Columns.Add(tbCol);

tbCell = new DataGridViewTextBoxCell();
tbCol = new DataGridViewColumn();
tbCol.Name = "CheckDate";
tbCol.HeaderText = "Check date";
tbCol.CellTemplate = tbCell;
tbCol.Width = this.Font.Height * 15;
InGrid.Columns.Add(tbCol);

tbCell = new DataGridViewTextBoxCell();
tbCol = new DataGridViewColumn();
tbCol.Name = "CheckAmt";
tbCol.HeaderText = "Check amount";
tbCol.CellTemplate = tbCell;
tbCol.Width = this.Font.Height * 15;
InGrid.Columns.Add(tbCol);
}
 
C

ClayB

There is no Caption property in a DataGridView. You could use a Panel
where you wnt the grid, docking a Label to the top of it. Then you
could then dock.Fill a DataGridView in the panel as well. This would
give you th eeffect of a caption above the DataGridView.

===============
Clay Burch
Syncfusion, Inc.
 
S

Steve Richter

There is no Caption property in a DataGridView. You could use a Panel
where you wnt the grid, docking a Label to the top of it. Then you
could then dock.Fill a DataGridView in the panel as well. This would
give you th eeffect of a caption above the DataGridView.

that helps. thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top