473,382 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

DataGrid

palanivel
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 ........
Jun 26 '07 #1
1 816
dip_developer
648 Expert 512MB
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

Expand|Select|Wrap|Line Numbers
  1.  
  2. 'Suppose dsProduct is the Dataset you are using to bind the grid.
  3. 'Suppose dgProduct is the Datagrid 
  4.  
  5. dgtsProduct = New DataGridTableStyle
  6. dgtsProduct .MappingName = dsProduct.Tables(0).TableName.ToString
  7. Dim txtProdName As DataGridTextBoxColumn = New DataGridTextBoxColumn
  8. txtProdName .MappingName = "Product_Name"
  9. txtProdName .HeaderText = "Product Name"
  10. txtProdName .Width = 85
  11. txtProdName .TextBox.BackColor = Color.LightBlue
  12. dgtsProduct .GridColumnStyles.Add(txtProdName )
  13. dgProduct.TableStyles.Add(dgtsProduct )
  14.  
Jun 26 '07 #2

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

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
3
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found...
5
by: BBFrost | last post by:
Win2000 ..Net 1.1 SP1 c# using Visual Studio Ok, I'm currently in a "knock down - drag out" tussle with the .Net 1.1 datagrid. I've come to realize that a 'block' of rows highlighted within...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
3
by: CVerma | last post by:
Hi, I have an embedded datagrid within a datalist. I am not able to perfrom paging in the datagrid. Any ideas? Here is my code: Here is my Simplegrid.cs file: using System; using...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
7
by: Dave | last post by:
Are there any add-on products or samples available that can do the following in an vb.net datagrid I want to compare 2 rows in a datagrid - one row from one database and another row for another...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
2
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.