| | |
Show all text in datagrid
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Sep 2006
Posts: 88
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
| Thread Tools | Search this Thread |
"crystal .net .net2008 2008 access add advanced application array assignment basic beginner box browser button buttons center click code combo convert cpu cuesent data database datagrid datagridview datetimepicker designer dissertation dissertations dissertationtopic dosconsolevb.net editvb.net employees excel exists firewall forms html images isnumericfuntioncall listview map math memory mobile module msaccess mssqlbackend mysql navigate net number opacity open pan pdf picturebox picturebox2 port print printpreview record regex reuse right-to-left save search serial settings socket sorting sqldatbase sqlserver storedprocedure temp textbox timer timespan transparency txttoxmlconverter upload useraccounts usercontol vb vb.net vb.nettoolboxvisualbasic2008sidebar vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web wpf wrapingcode xml year






