How to detect whether Panel got scrollbar ?

G

Guest

Hi,

I have a listview inside a panel and i want to know how to dectect whether
the autoscrollbar of the panel has been activated? The reason is that i need
to resize the column of the listview if the panel scrollbar is visible.

Regards,
Dylas
 
D

Daniel Moth

Can you not just compare the height of the panel with he height of the
listview? When their difference is less than X you have scrollbars visible.
X will be different depending on what distance you left between the listview
and the panel edge.

Cheers
Daniel
 
G

Guest

Hi Daniel Moth,

Thanks for ur suggestion.
I tried out ur method and the problem is that the ListView is dock in the
panel container and the height of the ListView is always the same as the
panel ..

Sorry, new to all this.

Regards,
Dylas
 
G

Guest

Hi Daniel Moth,

Thanks for ur suggestion.
I tried out ur method and the problem is that the ListView is dock in the
panel container and the height of the ListView is always the same as the
panel ..

Sorry, new to all this.

Regards,
Dylas
 
G

Guest

Hi Daniel,

The situation is like this, I put a ListView inside a Panel(Both of them are
of same width and height) and inside the ListView i will load rows of data
into it. And the sum of the columns width in the ListView will be 240 and if
the rows exceed the height of the Panel(which is the same with the ListView
height), vertical scrollbar(because of too many rows) and horizontal
scrollbar(because deivce width is 240 and now add on a vertical scrollbar)
will auto on, so in this situation i would like to resize the the Columns of
the Listview in order to prevent the horizontal scrollbar from appearing.

Thank You for your prompt replies.

Regards,
Dylas
 
D

Daniel Moth

OK, I think I can visualise your scenario now.

You have a listview in a panel and they remain the same size as each other
throughout their lifetime? The obvious question is, why are you using a
panel and not the listview on its own?

You say you can see scrollbars when adding items that exceed the height of
the listview. You can workout how many listview items the listview has and
when it exceeds a certain number *then* do your resizing. You can get the
listviewitem height by sending a msg to the listview with argument:
LB_GETITEMHEIGHT (google/msdn it).

However, I would take a step back and look at the overall situation. Take
the listview out of the panel unless you have a good reason. The scrollbars
you are seeing will appear in any case. They will be from the listview
itself. To avoid the scrollbars (regardless of the control they belong to),
simply make the columns of your listview smaller from the start. In other
words, anticipate that you will get scrollbars and size everything once.
Sure you'll have about 20 pixels on the right unused in some circumstances
but that is better than all this messing around in my opinion.

Cheers
Daniel
 
G

Guest

HI Daniel Moth,

Tried ur method of getting the listview item height but i cant use the
method as for Smart Device ListView.hWnd is not support and it is one of the
parameter in the sendMessage(). Please help me as i am struck with this
problem for a very long time. Thank You all ...

As below is my coding for the SendMessage

Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

SendMessage(ListView.hWnd, LB_GETITEMHEIGHT, 0&, 0&)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top