listbox

C# How to select ListBox item with a RightClick?

∥☆過路亽.° 提交于 2019-12-12 14:22:30
问题 I have tried a lot of methods for this and done hours of research, but it just never seems to work for me. This is my current code, and I don't know why it shouldn't work. private void listBox1_MouseDown(object sender, MouseEventArgs e) { listBox1.SelectedIndex = listBox1.IndexFromPoint(e.X, e.Y); if (e.Button == MouseButtons.Right) { contextMenuStrip1.Show(); } } Also I don't care about the context menu that can be removed I am just looking for a way to make the right mouse button select the

Html.ListBoxFor error problem asp.mvc 3

家住魔仙堡 提交于 2019-12-12 13:32:27
问题 I have something like this in my code and I am getting error: Exception Details: System.ArgumentException: Value cannot be null or empty. Parameter name: name . What am I doing wrong ? Thanks for help @model IEnumerable<NHibernateFluentProject.Patient> @Html.ListBoxFor(model => model, new SelectList(Model,"ID", "FirstName")); 回答1: @Html.ListBoxFor is used for your strong typed viewmodel. which could help to bind to your property. First part will take a lambda expression for a single item as a

limit selections in a listbox in vb.net

做~自己de王妃 提交于 2019-12-12 12:42:47
问题 I am creating a web control in vb.net that contains a list box. I know that I am able to choose a selection mode of Single or Multiple, but I am interested in limiting a Multiple selection to a predetermined size. For example preventing a user from selecting more than 3 items. I have tried adding a Validator to the list box, which might be a way forward, but was wondering if there was a way of changing the selection mode to something a bit different than just the two specified ones. Any ideas

add images to listbox (visual basic)

时光总嘲笑我的痴心妄想 提交于 2019-12-12 10:55:53
问题 I have sets of web hosted images that I need my user to be able to select 1 from each. I thought a listbox would work for this, but I can't figure out add an image to one. Is this possible? better way of doing this? I am using the latest free vb. 回答1: Use the Listview control instead, it provides better functionality, and doesn't suffer from an annoying resize bug. The listbox is carried over from VB6 days. The listview supports column headers, groupings and a bit more. Add a Imagelist

Silverlight: Datagrid like grouping in ItemsControl

被刻印的时光 ゝ 提交于 2019-12-12 10:37:34
问题 Is it possible to group items in a ItemsControl or Listbox in Silverlight? These controls are bound to a DomainDataSource. Or are there any 3rd party controls that do this? UPDATE: This is the sort of UI I am trying to create. 回答1: You can do this by using nested ItemsControls bound to a PagedCollectionView. Say I have a datasource - MyItems - with fields: Category , Section and Option . I can create a PagedCollectionView from an IEnumerable(of MyItems) and tell it which fields to group by.

All ComboBoxes in a ListBox change when any 1 of them is changed

柔情痞子 提交于 2019-12-12 09:43:16
问题 I have a ListBox on a form that is bound to an ObservableCollection of a custom type. Within each item there is a ComboBox bound to an enumeration type. When the window loads, all ComboBox es are defaulted to a certain value. When I change the SelectedItem for any one (from the UI, not from code), all other ComboBox es change to the same SelectedItem . I'm not sure what I've done wrong, here is my current XAML that is handling this. <Window.Resources> <ObjectDataProvider x:Key=

WPF Listbox - Empty List Display Message

非 Y 不嫁゛ 提交于 2019-12-12 09:31:49
问题 Can anyone suggest the best way to display a Textblock (with a text such as "List Empty") so that it's visibility is bound to the Items.Count. I have tried the following code and can't get it to work, so think that I must be doing it wrong. <ListBox x:Name="lstItems" ItemsSource="{Binding ListItems}"> </ListBox> <TextBlock Margin="4" FontStyle="Italic" FontSize="12" Text="List is empty" Visibility="Collapsed"> <TextBlock.Style> <Style TargetType="{x:Type TextBlock}"> <Style.Triggers>

GWT ListBox - how to have a listbox item disabled?

别等时光非礼了梦想. 提交于 2019-12-12 08:33:55
问题 How can I have the first item in a listbox disabled? Following is my code: ListBox list = new ListBox(); list.addItem("Select an item"); list.addItem("a"); list.addItem("b"); list.addItem("c"); How do I disable the first item in list? Thanks so much 回答1: You could select the first child element and set the disabled atribute: list.getElement().getFirstChildElement().setAttribute("disabled", "disabled"); 回答2: For anyone who finds this page and is looking to disable a GWT ListBox option which is

Double buffered ListBox

喜欢而已 提交于 2019-12-12 07:57:36
问题 I have a CheckedListBox (WinForms) control (which inherits from ListBox; googling shows that the problem is with ListBox) that is anchored to all four sides of its form. When the form is resized, the ListBox has an ugly flicker. I tried inheriting CheckedListBox and setting DoubleBuffered to true in the ctor (this technique works with other controls, including ListView and DataGridView), but it had no effect. I tried adding the WS_EX_COMPOSITED style to CreateParams , and this helped, but

WPF Single selection between two ListBoxes

北城以北 提交于 2019-12-12 07:57:34
问题 I'm having the following problem: I have two ListBox , with two different ItemSource , but both of them have the same binding for the SelectedItem , because I was trying to perform a single selection between these two lists. Here's an image that better shows the problem: What would I like to do? Every time I select one item from the first list (in red), it should deselect the SelectedItem from the second list (in black), and vice versa. That's why I'm using the same binding for both of them.