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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can we place a tooltip on the actual vb6 form 5 56
vbModal 12 72
Copy a range from 1..n excel sheets to one destination sheet 2 71
Error with a code discussed on this page 5 46
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

731 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