hi friend,
i am creating VB.NET windows application, i am used in datagrid ..database field is EMP NAME,ID,PLACE how to type the datagrid heading ........
what do u want...Column header??? or datagrid caption????
if u execute a sql query and bind the datagrid with the table records then by default the field name of the table(or the alias name of the field you use in sql statement) will be displayed as the column header.
If your sql looks like the following.
SELECT Product_ID,Product_Name,Product_Price FROM tblProducts
then Datagrid column header will be
Product_ID | Product_Name | Product_Price
If your sql looks like the following.
SELECT Product_ID AS ID,Product_Name AS Name,Product_Price AS Price FROM tblProducts
then Datagrid column header will be
ID | Name | Price
But If you want to organize the header text,width,height according to your choice then you have to use
DataGridTableStyle.
I am giving you one example how you can add a TextBox in a datagrid column/Give a header text and manage the width of column using
DataGridTableStyle -
-
'Suppose dsProduct is the Dataset you are using to bind the grid.
-
'Suppose dgProduct is the Datagrid
-
-
dgtsProduct = New DataGridTableStyle
-
dgtsProduct .MappingName = dsProduct.Tables(0).TableName.ToString
-
Dim txtProdName As DataGridTextBoxColumn = New DataGridTextBoxColumn
-
txtProdName .MappingName = "Product_Name"
-
txtProdName .HeaderText = "Product Name"
-
txtProdName .Width = 85
-
txtProdName .TextBox.BackColor = Color.LightBlue
-
dgtsProduct .GridColumnStyles.Add(txtProdName )
-
dgProduct.TableStyles.Add(dgtsProduct )
-