I have a list-box with some items in it. When i click on one item its selected.
But when i press Ctrl + click on same selected item then it will unselected and total no of selected items in list-box is zero.
So i want list-box should always have minimum one selected item.
Any suggestion.
Have you tried setting the SelectionMode property to "Multiple"?
Related
I'm working on code that creates a form with two list boxes. In the first list box I'm listing a set of items in a Civil 3D file (wich is already working). In the second list box I want to show all the sub items of the items that are listed in the first list box.
In other words, when I open the form, the first list box contain all the items (already working), when I click or double click one of this items, the second list box will list all the sub items that is in this item that I clicked.
Any ideas in how to do it?
Listbox 1 contains names of hairdressers and Listbox 2 contains services provided by all of them then in Listbox 3 both the selected hairdresser(only 1 allowed) and and selected services are contained. There is a remove button which removes items from Listbox 3. I want a code for the button that if a hairdresser is removed all services also get removed otherwise only services are removed.
For Each str As String In Hairdresser.lstHairdresser.Items
If Not lstHairdresserAndServices.Items.Contains(str) Then
lstHairdresserAndServices.Items.Clear()
Else
'more code here but above statement never gets true
End If
Next
If the hairdresser is always the first item in the 3rd listbox, all you have to do is check if the selectedindex equals 0. If so, clear the listbox. Otherwise just remove the selected item.
Alternatively, you could search the the 1st listbox for the selected string. If found clear the listbox otherwise remove the selected item.
It is also possible to mark the listbox items when you add then to the listbox. Set the tag property to something like "hairdresser" or "service" and when the remove button is clicked all you have to do is check the tag property.
Finally I would recommend a different approach: Instead of adding the items to the listbox, fill a data structure with the hairdresser's name and services, display this structure in the listbox and when the remove button is clicked compare the selected item to the structure to find out what was selected.
I have a ASPXGridview with a button as the first column for each of the rows. When I click a button I want it to perform a callback which will get me the value of the cell next to the button click. I'm a bit stuck on this so any advise would be great.
Thanks
I created a call back function to get key field name from a row on selection changed.
Then when I click on the button is gets the selected keys on the page.
What i wanted is after binding combobox, the first item ( first item will be always header like 'Select Item') need to be in selected style, means the blue back color and typing will overwrite that item (autocomplete starts then).
dropdownstyle is dropdown so that user can type inside combobox.
Wanted like this
When the combobox gets focus the text will be selected automatically.
If you want the combobox to get focus right after the binding you can use
ComboBox1.DataSource = oDataSource
ComboBox1.Focus()
There are two methods :
comboBox1.Focus();
or
comboBox1.select(0, comboBox1.text.Length);
I want to clear dataview item when it lost focus, mean when user click somewhere else x-item-selected class is removed from current selected item.
you can use
dataview.getSelectionModel().deselectAll();
to remove the selection