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

Posted on 2001-08-29
Medium Priority
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 600 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


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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 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…
Suggested Courses
Course of the Month8 days, 11 hours left to enroll

764 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