Does any one have the idea how to make two listbox or textbox...act like radio button..
Which means When i select the items form listbox1...
i should not be able to select from listbox2..
Thanks
Printable View
Does any one have the idea how to make two listbox or textbox...act like radio button..
Which means When i select the items form listbox1...
i should not be able to select from listbox2..
Thanks
will you pls. explain a little bit broad on your problem.Quote:
Originally posted by toytoy
Does any one have the idea how to make two listbox or textbox...act like radio button..
Which means When i select the items form listbox1...
i should not be able to select from listbox2..
Thanks
is this master-detail relationship?
listbox1 is the master and listbox2 are the details?
At first both listbox is enabled and can be choose if something is inside..
But if i choose either of the listbox....the other will automatic be disabled... that means i should not select from both listbox at the same time...
Then when i click on another button both listbox will be enable again...
just does not want both to be selected at the same time when only one is being selected first ..
Thanks
Quote:
Originally posted by toytoy
At first both listbox is enabled and can be choose if something is inside..
But if i choose either of the listbox....the other will automatic be disabled... that means i should not select from both listbox at the same time...
Then when i click on another button both listbox will be enable again...
just does not want both to be selected at the same time when only one is being selected first ..
Thanks
VB Code:
Private Sub ListBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseUp ListBox2.Enabled = False End Sub Private Sub ListBox2_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox2.MouseUp ListBox1.Enabled = False End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ListBox1.Enabled = True ListBox2.Enabled = True End Sub
here try this one.
:afrog:VB Code:
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ListBox1.Enabled = True ListBox2.Enabled = True End Sub Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown If e.Button = MouseButtons.Left Then ListBox2.Enabled = False End If End Sub Private Sub ListBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox2.MouseDown If e.Button = MouseButtons.Left Then ListBox1.Enabled = False End If End Sub
Thanks it works...
But how to make the highlight thing disappear when one items is being choosen and reset...
add this in the button event:
ListBox1.SelectedIndex = -1
ListBox2.SelectedIndex = -1
:afrog:
Thanks everyone....
Both methods works well..
:wave:
cheers us all :thumb:
Another quick problem...
How to tell the listbox if i select the items form either listbox...
That means if i select the item in either listbox, the items should be able to appear in TextBox1...
try this one.
:afrog:VB Code:
Private Sub Lstb_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged, ListBox2.SelectedIndexChanged If sender.name = "ListBox1" Then TextBox1.Text = ListBox1.SelectedItem Exit Sub Else TextBox1.Text = ListBox2.SelectedItem Exit Sub End If End Sub
what is your Lstb refer to...
listbox1 or listbox2..
Thanks
It can works.....
but it skip my button...
That means if i click on the listbox, it will appear in the textbox without having to click the button....
Thanks
refer to the listbox1 and listbox2 that it is...both of it will trigger but i have a condition their that will trap each of it (sender.name) on what listbox you selected...Quote:
Originally posted by toytoy
what is your Lstb refer to...
listbox1 or listbox2..
Thanks
in other way, you can use this...
VB Code:
Private Sub ListBox1_SelectedIndexChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged and Private Sub ListBox2_SelectedIndexChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox2.SelectedIndexChanged
hope it helps :afrog:
what are you trying to achieve? you mean that after the button event then the selected items in the listbox will appear in the textbox, is that? or i am misleading. :bigyello:Quote:
Originally posted by toytoy
It can works.....
but it skip my button...
That means if i click on the listbox, it will appear in the textbox without having to click the button....
Thanks
yeah....
i want the event to occur only after i click on the button...
For the code that you given, it will automatic appear to the textbox....
forget to mention it before posting the question...
:rolleyes:
Thanks
this one, hopes got it :bigyello:
:afrog:VB Code:
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click If ListBox1.Enabled Then TextBox1.Text = ListBox1.SelectedItem ElseIf ListBox2.Enabled Then TextBox1.Text = ListBox2.SelectedItem End If ListBox1.Enabled = True ListBox2.Enabled = True ListBox1.SelectedIndex = -1 ListBox2.SelectedIndex = -1 End Sub
you are really great....
no matters how i ask, you could solve it...
Now all the problems are solve...
Thanks fret
happy coding :afrog: