Hi!
please find the word document as enclosed.
in that word document you fill find all the scenarios which i have taken as a snapshot.
i have a combobox and im displaying all the columns in that combobox.
you have 3 options here 1) Supress 2) Lock 3) Hide.
now i want to store these information because when the user switches to another column it should display its status.
now to store information of these columns.
i dont want to save this in database since its not necessary.
can i use a structure to store information or what should i do in storing the information.
if im using stucture then i have 7 columns & 3 states(supress,hide,lock) so 7*3 =21 variables or like how to do this easily.
pls help me in this regard.
i just need some develoment solutions for this.
what best i can use in order to store information.
with regards!
Sethuraman R
Dim Myvar()
Dim i, j As Integer
Private Sub Command1_Click()
List1.Clear
For j = 0 To i - 1
List1.AddItem Myvar(j)
Next
i = 0
End Sub
Private Sub Form_Load()
Combo1.AddItem "a"
Combo1.AddItem "b"
Combo1.AddItem "c"
Combo1.AddItem "d"
For i = 0 To Combo1.ListCount - 1
ReDim Preserve Myvar(i)
Myvar(i) = Combo1.List(i) 'storing values
Next
End Sub
Hi!
Thanks for the code but how to display the previous saved state.
have a look at the word doucment as enclosed in my previous post.
first i will select description from the combobox and will apply the hide check box &then i will select the next column say uom in the combobox and then apply the lock option for this column.
now if i again select the first column say description then the option hide should be cheked.
i.e how to maintain the previous state...
pls help me in this regard.
with regards!
Sethuraman R
One easy way is to use bitwise operations
Supress=1:Hide=2:Lock=4
Each time one of the checkboxes are clicked, update the itemdata for the combobox item...
I don't know if your checkboxes are arrayed or each is an individual control name. I will assume the former. Adjust code as needed for control names
Code:
Private Sub chkOptions_Click(Index As Integer)
' each check box is indexed: 0, 1, 2
' update the itemdata to the new options
Dim lOptions As Long
if cboItems.Tag = "no update" Then Exit Sub ' see cboItems_Click()
If cboItems.ListIndex = -1 Then Exit Sub
lOptions = cboItems.ItemData(cboItems.ListIndex)
Select Case Index ' toggle options
Case 0 ' suppress
lOptions = lOptions Xor 1
Case 1 ' hide
lOptions = lOptions Xor 2
Case 2 ' lock
lOptions = lOptions Xor 4
End Select
cboItems.ItemData(cboItems.ListIndex) = lOptions
End Sub
Private Sub cboItems_Click()
Dim lOptions As Long
cboItems.Tag = "no update" ' prevent checkboxes from updating itemdata
lOptions = cboItems.ItemData(cboItems.ListIndex)
chkOptions(0).Value = (lOptions And 1) ' supress
chkOptions(1).Value = (lOptions And 2) \ 2 ' hide
chkOptions(2).Value = (lOptions And 4) \ 4 ' lock
cboItems.Tag = ""
End Sub
Edited: If you are already using the itemdata property of the combobox items, then an array would be a good alternative.
Last edited by LaVolpe; Sep 15th, 2009 at 04:07 PM.
Insomnia is just a byproduct of, "It can't be done"