Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: .NET
Expertise: Intermediate
Nov 6, 2009

Quickly Determine Whether a Column Is Fully Visible in a DataGridView

It's easy to determine whether a DataGridView column is invisible—just check its Boolean Displayed property. However, the Displayed property returns True even when the column is only partially visible in the screen.

You can use the DataGridView.GetColumnDisplayRectangle method to create a solution for this problem.

The second parameter to GetColumnDisplayRectangle is called CutOverFlow, which is a Boolean value that controls whether the function returns the complete column rectangle (even if the column is not completely visible) or only the portion of the column's rectangle that is visible.

By calling this method twice, once with CutOverFlow set to true and once with it set to false, you can create a function that compares the results and returns a Boolean value when the column is only partially visible:

Return dg.GetColumnDisplayRectangle(columnindex, False).Width = _ 
   dg.GetColumnDisplayRectangle(columnindex, True).Width
Srinath MS
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap