msflexgrid, need to determine if column is visible within users viewing area

Posted on 2001-08-29
Last Modified: 2012-06-27
I have a grid with 13 columns. The last 3 columns aren't visible to the user because of the size of the grid. I need to determine this some how. When I scroll over I want to know when they become visible (to the user).

I tried .ColIsVisible - seemed like a piece of cake. NOT, this returns wether the column is hidden or not. The columns aren't hidden, they just aren't in the viewable area.

I tried comparing the grids.width to the columns.CellLeft, this didn't work. It returned what looks like a bad value when the column is outside the viewable area.

So I need some way to tell if a column is within the users viewable area or it's outside.

Question by:RPWard
LVL 44

Expert Comment

ID: 6437158
am I missing something, or did you not provide the answer yourself:

"I tried comparing the grids.width to the columns.CellLeft, this didn't work. It returned what looks
like a bad value when the column is outside the viewable area."  

Can't you test for that "what looks
like a bad value", and use that to indicate that the column is outside the viewable area?

Expert Comment

ID: 6437239

I'm curious ... *why* do you want to know when the column is scrolled into the viewable area ... what is your program going to do at that time?

Accepted Solution

kuppachi earned 200 total points
ID: 6437461
colisvisible(colindex) returns true or false depending on whether the column is in the visible area or not. And not whether it is hidden or not.

try this code before the last column is visible and after u scroll to the last column.

Private Sub Command1_Click()
MsgBox MSFlexGrid1.ColIsVisible(12)
End Sub
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.


Expert Comment

ID: 6437503
The CollsVisible do return if or not the column is in the viewable area...... maybe you are ont using the right index number?
LVL 27

Expert Comment

ID: 6437520
Yep, I think kuppachi is right.
I checked it with this code

Private Sub MSFlexGrid1_Scroll()
 If MSFlexGrid1.ColIsVisible(12) Then
    MsgBox "here is the first view of cell Scroll 12"
 End If
End Sub

Author Comment

ID: 6437671
Bad Value - something less than the grid.width. Looks like columns that are outside the viewable area are just behind the last column as fas as .CellLeft is concerned.

Author Comment

ID: 6437756
Thanks, you were right. I was looping through all the columns and part of the loop was changing the current col and row (which I reset at the end of the loop). Problem was - changing the current col and row also changed (I guess) the viewable area, so the ColIsVisible as true. But not when the current col and row were reset.

Your answer helped me find the problem, thanks again.

Expert Comment

ID: 6437825

I'm still curious.  What special thing are you wanting to do when a certain column comes into view?

-Dennis Borg

Author Comment

ID: 6440662
Dennis, I am about to put up another question. Trying to get the headers to merge cells, but still have select highlight on.

What I was playing around with was placing a label (actually a picture box with a label in it) on top of the column header cells I wish to merge. Wish they had a "center across cells" option when building the fixed headers.

Got it to work, but don't like it much. Have to put all kinds of code on labels when clicked on to act like clicking on column headers.

Thanks for being curious  :)

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question