Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

list of CheckBoxes in a ScrollBox

Status
Not open for further replies.

zvikorn

Programmer
Aug 6, 2003
17
0
0
US
Hi,
I create a groupList and fill it with many CheckBoxes.
bacuase of so many CheckBoxes, the ScroolBox control gets its Vertical Scroll Bar.
Whenever I try to click (check/uncheck) on a CheckBox in the middle of the list, the row of this CheckBox skips down to the bottom of the ScrollBox, and the checkBox is not being checked.
To make it more clear, imagine the ScrollBox as a square with the scroll Bars, and within the square we have 4 rows of CheckBoxes( 4 from many other). if you try to click on the CheckBox in the second row, this row becomes the forth row in the ScrollBox, the row that was first becomes the third, and the first and second rows now, are the rows that exist above the original rows.
I would appreciate your help.
zvikorn
 
I tested this out with Borland 6.0 professional, by statically placing the checkboxes in a scrollbox, but had no problems similar to what you have. What version are you using? Are you sure you aren't calling some code related to scrolling, or code that makes the control visible?

Chris
 
Hi,
I'm using the same Borland 6.0.
It dosnt matter if I do this in design time as you did or dynamically.there is no any code related to the scrolling.
When y ou tried in design time, did you places many rows of chckboxes in the scrollbox, and made the scrollbox smaler, in order to have scrollbars? this is thw way I did it. and then I just moved the scrollbars to the middle to reach the 10th row (for example) and in the window I saw only 4 rows. Then I encouter the problem.
Thanks a lot.
zvikorn
 
Hi,
Tip - It happens only in CLX form.
zvikorn
 
Ah, probably a CLX bug, can't think of why it would do it otherwise. :)
 
Hi, Thanks for the info.
So, if I want to use a groupBox instead the scrollbox and attach a scrollbar to it, what do I write in the code in order to move those rows of CheckBoxes when I move the scroll bar?
Thanks
zvikorn
 
Well you need to keep track of several things:

1) Total width of the groupbox if all components are taken into account.
2) Total height of the groupbox if all component are taken into account.

You would make the Min value of the scrollbar 0 of course and make the Max value the value of the furthest component's Left property plus it's width property.

Then in the OnChange event for the scrollbar,

static LastPosition = 0;

GroupBox1->ScrollBy(LastPosition - ScrollBar1->Position, 0);
GroupBox1->Repaint();
LastPosition = ScrollBar1->Position;

Everytime you add a new item to the groupbox, increase the scrollbar's max property. This example assumes the horizontal bar. The vertical is the same, except you use the top property plus the Height property of the furthest control down in the group box.

Chris
 
Chris,
How do I make the scrollbar not to move with the groupbox?
Thanks
zvikorn
 
Set the scrollbar's Align property to alBottom for horizontal one and alRight for vertical one. :)
 
Hi :)
Im sorry to ask you so basic question. I dont know the Borland tool, and I need it for work ASAP.
So thanks for the previous answers. You helped me very much.
I have one more if you do not mind: When the Im scrolling the checkboxes list, the first Checkbox overrides the top border of the groupbox a bit, and the last one overrides the bottom.
What is the solution for this?
Thanks
 
Change the scrolling values a little bit to fix the minimum problem. i.e. Add a value of 10 to the max vertical size and see if that helps on the bottom half. For the top half, it sounds like you might need to create the first checkbox lower in the groupbox. If neither of these help, just use a trick of some sorts, like create a blank label where the first checkbox should be, then add the first checkbox 10 pixels below that, and at the bottom create the last checkbox and add a blank label 10 pixels below that. The user won't see the labels, but they will prevent the group box from limiting the scrolling a little bit more.

Chris
 
Hi,
So now I have another problem. Everything works fine when its in design time. When I carete everything dynamically, when I change the scrollbar, the method of this event( OnChange, OnScroll) is not called. I put a breakpoint there and nothing. For example:
void __fastcall MyClass::sbarMaintChange(TObject *Sender)
{
..
}

I tried the OnChange and the Scroll/OnScroll as well.
any idea?
Thanks
 
Hi,
I have the solution for the last one. Dont want to waste your time.
Thanks.
zvikorn
 
Hi again,
I tried what you suggested in order to solve the problem of the oveeride the border (the label, the min/max to scrollbar), and it still does'nt work. When I put the label, it moves within the GroupBox along with the CheckBoxes, because they have the same Parent (the GroupBox). So when you change the ScrollBar, all the components within the GroupBox are moving. Any other ideas?
Thanks For the effort.
zvikorn
 
I'm a bit confused as to the problem maybe. Could you explain it further? Maybe I'm misunderstanding.

Thanks!
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top