469,588 Members | 2,639 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,588 developers. It's quick & easy.

Datagrid with datatable

Hi everyone, I've created a form with a datagrid and a datatable here is a sample:

private System.Windows.Forms.DataGrid dataGrid1;
private DataTable A;

public POS()
// Required for Windows Form Designer support
dataGrid1.DataSource = A;

private void CreateDataTableA()
//rowcount = 0;

A = new DataTable("A");
DataColumn dtCol;
DataRow dtRow;
// Create ID column and add to the DataTable.
dtCol = new DataColumn();
dtCol.DataType= System.Type.GetType("System.Int32");
dtCol.ColumnName = "ID";
dtCol.AutoIncrement = true;
dtCol.Caption = "ID";
dtCol.ReadOnly = true;
dtCol.Unique = true;
// Add the column to the DataColumnCollection.
//Create BarCode Column
dtCol = new DataColumn();
dtCol.DataType= System.Type.GetType("System.String");
dtCol.ColumnName = "BarCode";
dtCol.AutoIncrement = false;
dtCol.Caption = "Barcode";
dtCol.ReadOnly = false;
dtCol.Unique = false;

The problem is that the caption does not show. Only the Column name does. Also the when in the datatable form evens such as keyup do not work.
Plus in the properties window for the datagrid I don't see anything for data.
(By the way I created the datagrid by dragging it from the toolbox. The datatable and everything else I wrote myself...)
Oct 26 '07 #1
3 1117
4,871 Expert 4TB
Caption is a property that is set to false by default:
ASP.NET Binding: DataGrid to Vertical Table
Oct 26 '07 #2
I have looked at this link, but the code:

grid.AutoGenerateColumns = false;

doesn't seem to work. grid does not contain AutoGenerateColumns

I'm using C# by the way
Oct 29 '07 #3
759 Expert 512MB
Don't use caption, Use HeaderText property,

<ASP: BoundColumn DataField="ColumnOne"
HeaderText="ColumnOne" HeaderToolTip="This is the tooltip for One.">
Oct 29 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Emerson | last post: by
3 posts views Thread by Newbie | last post: by
4 posts views Thread by Glenn Owens | last post: by
4 posts views Thread by The Alchemist | last post: by
4 posts views Thread by tshad | last post: by
8 posts views Thread by Strahimir Antoljak | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.