It's all about datagrid

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2005
Posts: 71
Reputation: NewVBguy is an unknown quantity at this point 
Solved Threads: 3
NewVBguy NewVBguy is offline Offline
Junior Poster in Training

It's all about datagrid

 
0
  #1
Jul 19th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 85
Reputation: williamrojas78 is an unknown quantity at this point 
Solved Threads: 4
williamrojas78's Avatar
williamrojas78 williamrojas78 is offline Offline
Junior Poster in Training

Re: It's all about datagrid

 
0
  #2
Jul 25th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 71
Reputation: NewVBguy is an unknown quantity at this point 
Solved Threads: 3
NewVBguy NewVBguy is offline Offline
Junior Poster in Training

Re: It's all about datagrid

 
0
  #3
Jul 26th, 2006
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

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
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 85
Reputation: williamrojas78 is an unknown quantity at this point 
Solved Threads: 4
williamrojas78's Avatar
williamrojas78 williamrojas78 is offline Offline
Junior Poster in Training

Re: It's all about datagrid

 
0
  #4
Jul 27th, 2006
yes sure, the tablestyles can be done with code:

  1.  
  2. Me.DataGrid1.TableStyles.Clear()
  3.  
  4. 'Step 1: Create a DataGridTableStyle & set mappingname to table.
  5. Dim tableStyle As New DataGridTableStyle
  6. tableStyle.MappingName = "Table1"
  7.  
  8. Dim column As New DataGridTextBoxColumn
  9. column.ReadOnly = True
  10. column.MappingName = "ID"
  11. column.HeaderText = "Event_#"
  12. column.Width = 50
  13. column.Alignment = HorizontalAlignment.Center
  14. tableStyle.GridColumnStyles.Add(column)
  15.  
  16.  
  17. column = New DataGridTextBoxColumn
  18. column.ReadOnly = True
  19. column.MappingName = "Date"
  20. column.HeaderText = "Date_Time"
  21. column.Width = 110
  22. column.Alignment = HorizontalAlignment.Center
  23. tableStyle.GridColumnStyles.Add(column)
  24.  
  25. tableStyle.AlternatingBackColor = Color.Lavender
  26.  
  27. 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
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 71
Reputation: NewVBguy is an unknown quantity at this point 
Solved Threads: 3
NewVBguy NewVBguy is offline Offline
Junior Poster in Training

Re: It's all about datagrid

 
0
  #5
Jul 28th, 2006
Wow... That's all I need to do. Thanks.... HOW can you this at design time. Is it possible?.
Thanks again.

Newvbguy


Originally Posted by williamrojas78
yes sure, the tablestyles can be done with code:

  1.  
  2. Me.DataGrid1.TableStyles.Clear()
  3.  
  4. 'Step 1: Create a DataGridTableStyle & set mappingname to table.
  5. Dim tableStyle As New DataGridTableStyle
  6. tableStyle.MappingName = "Table1"
  7.  
  8. Dim column As New DataGridTextBoxColumn
  9. column.ReadOnly = True
  10. column.MappingName = "ID"
  11. column.HeaderText = "Event_#"
  12. column.Width = 50
  13. column.Alignment = HorizontalAlignment.Center
  14. tableStyle.GridColumnStyles.Add(column)
  15.  
  16.  
  17. column = New DataGridTextBoxColumn
  18. column.ReadOnly = True
  19. column.MappingName = "Date"
  20. column.HeaderText = "Date_Time"
  21. column.Width = 110
  22. column.Alignment = HorizontalAlignment.Center
  23. tableStyle.GridColumnStyles.Add(column)
  24.  
  25. tableStyle.AlternatingBackColor = Color.Lavender
  26.  
  27. 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
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 85
Reputation: williamrojas78 is an unknown quantity at this point 
Solved Threads: 4
williamrojas78's Avatar
williamrojas78 williamrojas78 is offline Offline
Junior Poster in Training

Re: It's all about datagrid

 
0
  #6
Jul 28th, 2006
That is the way you do it at designt time.
Is that what you mean? is what possible?
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 71
Reputation: NewVBguy is an unknown quantity at this point 
Solved Threads: 3
NewVBguy NewVBguy is offline Offline
Junior Poster in Training

Re: It's all about datagrid

 
0
  #7
Jul 28th, 2006
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


Originally Posted by williamrojas78
That is the way you do it at designt time.
Is that what you mean? is what possible?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC