| | |
Show all text in datagrid
Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Sep 2006
Posts: 90
Reputation:
Solved Threads: 0
Now that I can see the data in the datagrid, I realize that the size of the fields is too small - the customerid and customer name fields both could use expanding so that I can see all of the text. Is there a way to programmatically extend the length of the field so that it can show the entire string?
•
•
Join Date: Nov 2008
Posts: 63
Reputation:
Solved Threads: 10
Something like this?
It will expand the last column in the datagridview. You can edit it to your needs :=)
It will expand the last column in the datagridview. You can edit it to your needs :=)
VB.NET Syntax (Toggle Plain Text)
Private Sub DataGridView1_DataBindingComplete(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewBindingCompleteEventArgs) Handles DataGridView1.DataBindingComplete Dim _DGV As DataGridView = DirectCast(sender, DataGridView) _DGV.Columns(_DGV.ColumnCount - 1).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill End Sub
•
•
Join Date: Nov 2008
Posts: 63
Reputation:
Solved Threads: 10
To help you a little more:
You also can add a ContextMenuStrip to your solution and respond on the rightclicking of a user into one of the columns in your datagrid.
For example, if the user rightclicks into a column a menuitem will be shown with "show all data". If clicked, that particular column will be autosized.
Add the variabele _ActiveColumn to the general declaration section.
Add a contextmenu to your solution with 1 item "Show all data"
You also can add a ContextMenuStrip to your solution and respond on the rightclicking of a user into one of the columns in your datagrid.
For example, if the user rightclicks into a column a menuitem will be shown with "show all data". If clicked, that particular column will be autosized.
Add the variabele _ActiveColumn to the general declaration section.
Add a contextmenu to your solution with 1 item "Show all data"
VB.NET Syntax (Toggle Plain Text)
Private _ActiveColumn As Integer = 0 Private Sub DataGridView1_CellMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseDown _ActiveColumn = e.ColumnIndex If e.Button = Windows.Forms.MouseButtons.Right Then Me.ContextMenuStrip1.Show(Me.DataGridView1, New Point(e.X, e.Y)) End If End Sub Private Sub ShowAllDataToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowAllDataToolStripMenuItem.Click For Each oCol As DataGridViewColumn In Me.DataGridView1.Columns If oCol.Index = _ActiveColumn Then oCol.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill Else oCol.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells End If Next End Sub
![]() |
Similar Threads
- collect data from datagrid (Visual Basic 4 / 5 / 6)
- Insert & Edit Data in DataGrid (VB.NET)
- how to read data from text file into data grid??? (VB.NET)
- Need help to finish datagrid problem (VB.NET)
- Datagrid - no value at index ### error when scroll and sort (VB.NET)
- How to Show Database In DataGrid Using DAO (Visual Basic 4 / 5 / 6)
- DataGrid with ado.net. (VB.NET)
- Deleting a Row From A DataGrid (VB.NET)
- The Datagrid: How does one fill text boxes in edit mode with their original content? (ASP.NET)
- refresh datagrid causes error if oper scrolled off right side of grid (VB.NET)
Other Threads in the VB.NET Forum
- Previous Thread: VB 2008 INSERT into MS Access Error
- Next Thread: how to deploy vb.net 2003 project
Views: 988 | Replies: 4
| 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 designer dissertation dissertations dissertationthesis dll dosconsolevb.net editvb.net employees error excel exists firewall folder 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 refresh regex reports" reuse save savedialog 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






