Datagridview question
Datagridview question
Datagridview question
Datagridview question
Datagridview question
Datagridview question Datagridview question Datagridview question Datagridview question Datagridview question Datagridview question Datagridview question Datagridview question
Datagridview question Datagridview question
Datagridview question
Go Back  Xtreme Visual Basic Talk > > > Datagridview question


Reply
 
Thread Tools Display Modes
  #21  
Old 10-17-2007, 03:14 AM
YaRoBi YaRoBi is offline
Regular
 
Join Date: Feb 2004
Location: Belgium - Aalst
Posts: 69
Default


Quote:
Originally Posted by IUnknown View Post
You can get the sum of the column widths by looping through the DGV column collection. Add to the sum the width of a few pixels (for borders) and assign the total to the DGV width.
In the help files aI found something like this but it won't work

Code:
Dim insta As DataGridViewColumnCollection
        Dim includeFilter As DataGridViewElementStates
        Dim returnValue As Integer

        insta = New DataGridViewColumnCollection(dgvBehandelingen)
        includeFilter = New DataGridViewElementStates
        returnValue = insta.GetColumnsWidth(includeFilter)

        TextBox1.Text = returnValue.ToString
Code:
Public Function GetColumnsWidth(ByVal includeFilter As DataGridViewElementStates) As Integer

    End Function

Last edited by YaRoBi; 10-17-2007 at 03:29 AM. Reason: was forgotten the Function to post
Reply With Quote
  #22  
Old 10-17-2007, 11:14 AM
IUnknown's Avatar
IUnknown IUnknown is offline
Senior Contributor

Forum Leader
* Expert *
 
Join Date: Oct 2004
Location: Montréal
Posts: 1,135
Default

To use the GetColumnsWidth method, you only need to pass one of the enumeration of DataGridViewElementStates, i.e.,
Code:
Dim w As Integer w = DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Displayed)
It is not necessary to create a new DataGridViewElementStates type.
__________________
win7 : vs 2008 : .Net 3.5
Reply With Quote
  #23  
Old 10-19-2007, 09:28 AM
YaRoBi YaRoBi is offline
Regular
 
Join Date: Feb 2004
Location: Belgium - Aalst
Posts: 69
Default

Quote:
Originally Posted by IUnknown View Post
To use the GetColumnsWidth method, you only need to pass one of the enumeration of DataGridViewElementStates, i.e.,
Code:
Dim w As Integer w = DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Displayed)
It is not necessary to create a new DataGridViewElementStates type.
And how do I set the dgv width = w + bordersize?
Reply With Quote
  #24  
Old 10-19-2007, 09:06 PM
IUnknown's Avatar
IUnknown IUnknown is offline
Senior Contributor

Forum Leader
* Expert *
 
Join Date: Oct 2004
Location: Montréal
Posts: 1,135
Default

bordersize will depend on how your DGV borders were set up. Is your DGV docked? If not the Width property of the DGV should work fine.

Are you using VB2005 Express or better? With VB2005 Express, you can easily browse through the available control properties and events by opening up the properties window while in the IDE. The intellisense provides the same information in code view via a drop down.
__________________
win7 : vs 2008 : .Net 3.5
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Datagridview question
Datagridview question
Datagridview question Datagridview question
Datagridview question
Datagridview question
Datagridview question Datagridview question Datagridview question Datagridview question Datagridview question Datagridview question Datagridview question
Datagridview question
Datagridview question
 
Datagridview question
Datagridview question
 
-->