|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Best method to have 2 checkboxes for 1 itemI've used a combination of a dropdown list and 2 x listboxes overlapped to give the user the ability to click on a drop-down and then scroll down a list to 'Include' or 'Exclude' an item depending on which checkbox they click, eg: Inc Exc [x] [ ] Computer Club [ ] [ ] Comes from overseas [ ] [x] Like Milk [ ] [x] Part time job etc... etc... This frankenstein control worked fine until I noticed that the 2 listboxes can't be kept in sync when scrolling so the checkboxes look like they are going wappie when the user uses the scrollbar. I'm desperately trying to resolve this, but I was wondering if there is a better control to get this effect - any ideas? Rgds "Mojo" <please@dont.spam.com> wrote in message Please don't post the same question multiple timesnews:%23PDfO4X$JHA.5092@TK2MSFTNGP03.phx.gbl... > Hi All "Mojo" <please@dont.spam.com> wrote in message You really are going to have to stop posting to all those groups, some of news:%23PDfO4X$JHA.5092@TK2MSFTNGP03.phx.gbl... > Hi All. I've used a combination of a dropdown list > and 2 x listboxes overlapped to give the user the > ability to . . . them separately, and also stop posting thread after thread on the same subject. Just post one thread and have a bit of patience! For what it's worth I posted a response to one of your threads in one of the groups (can't remember which thread or group now!) suggesting that you might like to use a scrollable PictureBox on the grounds that you can customise such an arrangement to work in just about any way you wish. Here, again, is my posted suggestion just in case you can't find it amongst all those groups and all those threads :-) It's just a "bare bones" test at the moment, but it can of course be customised in all sorts of different ways. To try it out start a new VB project and place two Picture Boxes, two Check Boxes, one Label Control and one Vertical ScrollBar on your Form. Make sure that in the IDE at design time you set the Index property of the two Check Boxes and the Label Control to zero (you need to select each of them and actually enter 0 into the Index property in the Properties window). Then paste in the following code and give it a run: Mike Option Explicit Private Sub Form_Load() Dim n As Long Dim s1() As String ReDim s1(0 To 49) s1(0) = "Computer Club" s1(1) = "Comes from overseas" s1(2) = "Likes milk" s1(3) = "Has part time job" ' etc, etc ' (it might be best to actually ' load these from a data file) Me.ScaleMode = vbPixels Picture1.ScaleMode = vbPixels Picture2.ScaleMode = vbPixels Picture1.Move 20, 20, 180, 250 Picture2.BorderStyle = vbBSNone Picture2.BackColor = vbWhite Picture2.Width = Picture1.ScaleWidth Set Picture2.Container = Picture1 Picture2.Move 0, 0 VScroll1.Move Picture1.Left + Picture1.Width, Picture1.Top, _ VScroll1.Width, Picture1.Height VScroll1.TabStop = False Set Check1(0).Container = Picture2 Check1(0).BackColor = vbWhite Check1(0).Caption = "" Check1(0).Move 4, 0, 20, 20 Set Check2(0).Container = Picture2 Check2(0).BackColor = vbWhite Check2(0).Caption = "" Check2(0).Move 24, 0, 20, 20 Set Label1(0).Container = Picture2 Label1(0).BackStyle = vbTransparent Label1(0).Move 44, 2, Picture2.Width - 44, 20 Label1(0).Caption = s1(0) For n = 1 To 49 ' a further 49 items Load Check1(n) Check1(n).Move 4, 20 * n, 20, 20 Check1(n).Visible = True Load Check2(n) Check2(n).Move 24, 20 * n, 20, 20 Check2(n).Visible = True Load Label1(n) Label1(n).Move 44, 2 + 20 * n, Picture2.Width - 44, 20 If s1(n) = "" Then Label1(n).Caption = "This is item number " & Format(n + 1) Else Label1(n).Caption = s1(n) End If Label1(n).Visible = True Next n Picture2.Height = n * 20 VScroll1.Min = 0 VScroll1.Max = Picture2.Height - Picture1.ScaleHeight VScroll1.Value = 0 VScroll1.SmallChange = 20 ' pixels per click VScroll1.LargeChange = 100 End Sub Private Sub VScroll1_Change() Picture2.Top = (-VScroll1.Value) End Sub Private Sub VScroll1_Scroll() Picture2.Top = (-VScroll1.Value) End Sub > Since Include is the opposite of Exclude, why> I've used a combination of a dropdown list and 2 x listboxes overlapped to > give the user the ability to click on a drop-down and then scroll down a > list to 'Include' or 'Exclude' an item depending on which checkbox they > click, eg: > > Inc Exc > [x] [ ] Computer Club > [ ] [ ] Comes from overseas > [ ] [x] Like Milk > [ ] [x] Part time job > etc... etc... can't you just use one listbox with a check for Include? (Checked means include, unchecked means exclude.) "mayayana" <mayaXXy***@rcXXn.com> wrote One possible example:> Since Include is the opposite of Exclude, why > can't you just use one listbox with a check for > Include? (Checked means include, unchecked > means exclude.) Search all newsgroups for the words 'Listbox' and 'Checkbox' but exclude those messages that include the word 'Net'. Include and exclude are both used.... ;-) LFS
Show quote
Hide quote
On Jul 5, 8:36 am, "Mojo" <ple...@dont.spam.com> wrote: Maybe this will give you a different direction to consider:> Hi All > > I've used a combination of a dropdown list and 2 x listboxes overlapped to > give the user the ability to click on a drop-down and then scroll down a > list to 'Include' or 'Exclude' an item depending on which checkbox they > click, eg: > > Inc Exc > [x] [ ] Computer Club > [ ] [ ] Comes from overseas > [ ] [x] Like Milk > [ ] [x] Part time job > etc... etc... > > This frankenstein control worked fine until I noticed that the 2 listboxes > can't be kept in sync when scrolling so the checkboxes look like they are > going wappie when the user uses the scrollbar. > > I'm desperately trying to resolve this, but I was wondering if there is a > better control to get this effect - any ideas? > > Rgds The Form_Load code is there just to load the list box for my test purposes and would have to be replaced with your specific code for loading the listbox with the appropriate information. Good Luck Private Sub Form_Load() For idx = 1 To 20 List1.AddItem ("[ ] - [ ] This is item " & idx) Next End Sub Private Sub List1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) Select Case X Case 100 To 210 If InStr(3, List1.List(List1.ListIndex), "X") > 0 Then List1.List(List1.ListIndex) = "[ ]" & Mid(List1.List (List1.ListIndex), 6) Else List1.List(List1.ListIndex) = "[ X ]" & Mid(List1.List (List1.ListIndex), 6) End If Case 420 To 530 If InStr(11, List1.List(List1.ListIndex), "X") > 0 Then List1.List(List1.ListIndex) = _ Mid(List1.List(List1.ListIndex), 1, 8) & "[ ]" & Mid (List1.List(List1.ListIndex), 14) Else List1.List(List1.ListIndex) = _ Mid(List1.List(List1.ListIndex), 1, 8) & "[ X ]" & Mid (List1.List(List1.ListIndex), 14) End If End Select End Sub
VB Express and VB files
Is my VB6 app form open? Vista 64 and Visual Studio 6 Keeping 2 listboxes in sync - VB6 ListBox - Limit Selection Rectangle Width Re: ADO: Deleting a table after it is loaded into Recordset In-Process and Out-of-Process Exporting a function from VB.net DLL CheckedListBox Selecting Items Control Snap Problem |
|||||||||||||||||||||||