| | |
It's all about datagrid
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2005
Posts: 71
Reputation:
Solved Threads: 3
Hi,
A newbie to vb.net and I am trying to learn this datagrid. Here are my questions:
1. How can I populate a datagrid with selected column of a table without using a query.
2. How can I put a variable column width
3. Can someone show me a code for searching
Thanks in advance.. Pls. it's easier for me to understand if a code is possible.
Newvbguy
A newbie to vb.net and I am trying to learn this datagrid. Here are my questions:
1. How can I populate a datagrid with selected column of a table without using a query.
2. How can I put a variable column width
3. Can someone show me a code for searching
Thanks in advance.. Pls. it's easier for me to understand if a code is possible.
Newvbguy
Hi
The way I populate a datagrid:
1- Create a dataset and a dataview.
2 - Get the database.
3 - Fill the dataset with the data from the database table.
4 - Set the dataview table to the dataset.
5 - Set the datasource of the datagrid to the dataview.
6 - Set the table style of the datagrid to show what you want to show.
- The column width you can set it up when setting the table style.
- If you want to filter the data, filter the dataview.
Hope it helps
The way I populate a datagrid:
1- Create a dataset and a dataview.
2 - Get the database.
3 - Fill the dataset with the data from the database table.
4 - Set the dataview table to the dataset.
5 - Set the datasource of the datagrid to the dataview.
6 - Set the table style of the datagrid to show what you want to show.
- The column width you can set it up when setting the table style.
- If you want to filter the data, filter the dataview.
Hope it helps
•
•
Join Date: Mar 2005
Posts: 71
Reputation:
Solved Threads: 3
Oh Thanks. It seems simple but ok, I am interested with the table style. Is this something you can do at design level, in coding/run time. Do you have some codings pls. Thanks again.
newvbguy
newvbguy
•
•
•
•
Originally Posted by williamrojas78
Hi
The way I populate a datagrid:
1- Create a dataset and a dataview.
2 - Get the database.
3 - Fill the dataset with the data from the database table.
4 - Set the dataview table to the dataset.
5 - Set the datasource of the datagrid to the dataview.
6 - Set the table style of the datagrid to show what you want to show.
- The column width you can set it up when setting the table style.
- If you want to filter the data, filter the dataview.
Hope it helps
yes sure, the tablestyles can be done with code:
That will add two of the columns ("ID" and "Date") from Table1 to datagrid1. There you can specify the text you want to display, width, etc.
there is more information here if you wnat to go deeper:
http://msdn.microsoft.com/library/de...stDataGrid.asp
VB.NET Syntax (Toggle Plain Text)
Me.DataGrid1.TableStyles.Clear() 'Step 1: Create a DataGridTableStyle & set mappingname to table. Dim tableStyle As New DataGridTableStyle tableStyle.MappingName = "Table1" Dim column As New DataGridTextBoxColumn column.ReadOnly = True column.MappingName = "ID" column.HeaderText = "Event_#" column.Width = 50 column.Alignment = HorizontalAlignment.Center tableStyle.GridColumnStyles.Add(column) column = New DataGridTextBoxColumn column.ReadOnly = True column.MappingName = "Date" column.HeaderText = "Date_Time" column.Width = 110 column.Alignment = HorizontalAlignment.Center tableStyle.GridColumnStyles.Add(column) tableStyle.AlternatingBackColor = Color.Lavender Me.DataGrid1.TableStyles.Add(tableStyle)
That will add two of the columns ("ID" and "Date") from Table1 to datagrid1. There you can specify the text you want to display, width, etc.
there is more information here if you wnat to go deeper:
http://msdn.microsoft.com/library/de...stDataGrid.asp
•
•
Join Date: Mar 2005
Posts: 71
Reputation:
Solved Threads: 3
Wow... That's all I need to do. Thanks.... HOW can you this at design time. Is it possible?.
Thanks again.
Newvbguy
Thanks again.
Newvbguy
•
•
•
•
Originally Posted by williamrojas78
yes sure, the tablestyles can be done with code:
VB.NET Syntax (Toggle Plain Text)
Me.DataGrid1.TableStyles.Clear() 'Step 1: Create a DataGridTableStyle & set mappingname to table. Dim tableStyle As New DataGridTableStyle tableStyle.MappingName = "Table1" Dim column As New DataGridTextBoxColumn column.ReadOnly = True column.MappingName = "ID" column.HeaderText = "Event_#" column.Width = 50 column.Alignment = HorizontalAlignment.Center tableStyle.GridColumnStyles.Add(column) column = New DataGridTextBoxColumn column.ReadOnly = True column.MappingName = "Date" column.HeaderText = "Date_Time" column.Width = 110 column.Alignment = HorizontalAlignment.Center tableStyle.GridColumnStyles.Add(column) tableStyle.AlternatingBackColor = Color.Lavender Me.DataGrid1.TableStyles.Add(tableStyle)
That will add two of the columns ("ID" and "Date") from Table1 to datagrid1. There you can specify the text you want to display, width, etc.
there is more information here if you wnat to go deeper:
http://msdn.microsoft.com/library/de...stDataGrid.asp
•
•
Join Date: Mar 2005
Posts: 71
Reputation:
Solved Threads: 3
oops sorry with my english. What I mean at design time is using the properties of the datagrid. to setup This is the time when you put a datagrid in a form. In other words setting up the table style without using a code.
thnx for the great help. now i am starting to grasp the power of vb.net
newvbguy
thnx for the great help. now i am starting to grasp the power of vb.net
newvbguy
•
•
•
•
Originally Posted by williamrojas78
That is the way you do it at designt time.
Is that what you mean? is what possible?
![]() |
Similar Threads
- binding a datagrid to a datareader (ASP.NET)
- Printing the datagrid control (ASP.NET)
- How to sort the rows in the datagrid and update it successfully? (VB.NET)
- Use of DataGrid (ASP.NET)
- Remove link frame around picture in Datagrid (ASP.NET)
- Linking to E-mail through datagrid (ASP.NET)
Other Threads in the VB.NET Forum
- Previous Thread: Excel Warning - Responsing through the Excel Object
- Next Thread: anyone know how to use zedgraph in vb.net?
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
"crystal .net .net2005 30minutes 2008 access add application array assignment basic binary box button buttons center click code connectionstring convert cpu data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dll dosconsolevb.net editvb.net employees error excel exists firewall folder function image images isnumericfuntioncall listview login math memory mobile module msaccess mssqlbackend mysql navigate net opacity page pan peertopeervideostreaming picturebox plugin port print printing printpreview problem record regex reports" reuse save savedialog search serial sorting sql sqldatbase storedprocedure string structures studio temp textbox timer upload useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet vista visual visualbasic visualbasic.net visualstudio2008 web wpf xml





