listbox

Get items from listbox in controller MVC ASP 4

☆樱花仙子☆ 提交于 2019-12-05 00:02:30
问题 I have a page where you can create channels. Channels have genres associated with them. CreateChannel.cshtml <h2>Create Channel</h2> <div class="row-fluid"> <div> @{ using (Html.BeginForm("CreateNewChannel", "Channel", new { channelId = Model.Id, userId = @Session["userId"] }, FormMethod.Post)) { @Html.HiddenFor(model => model.Id) <h5>Name</h5> @Html.TextBoxFor(model => model.Name, new { @class = "input-block-level pull-left", type = "text", required = "required", placeholder = "Channel Name"

Prevent duplicate items from being added to a ListBox

狂风中的少年 提交于 2019-12-04 23:07:58
问题 I have this code for adding selected items from one ListBox to another. How can I prevent the user from adding an item twice? I want the ListBox they are adding to lstBoxToUserProjects to only contain distinct items with no duplicate entries. protected void btnAddSelectedItem_Click(object sender, EventArgs e) { List<ListItem> itemsToAdd= new List<ListItem>(); foreach (ListItem listItem in lstbxFromUserProjects.Items) { if (listItem.Selected) itemsToAdd.Add(listItem); } foreach (ListItem

WPF Listbox - Empty List Display Message

三世轮回 提交于 2019-12-04 22:57:03
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> <DataTrigger Binding="{Binding ElementName=lstItems, Path=Items.Count}" Value="0"> <Setter Property="Visibility

ListBox with single select and also unselect on click…?

我是研究僧i 提交于 2019-12-04 22:53:52
I need a listbox that selects on first click and un-selects on second click, so that only zero or one item is selected at any time. The select/unselect is implemented in the listbox (with SelectionMode="Single") when you hold down crtl, but unfortunately, none of my users can be expected to know that. With SelectionMode="Multiple" we have the exact functionality I want, except that you can select more than one item... More background: I want the user to first choose which installation to log into, then to give credentials (and some other choices) To achieve this I have used a listbox with

Clear wpf listbox selection using button in control template and no codebehind

限于喜欢 提交于 2019-12-04 21:24:53
I want to create a Style for a WPF ListBox that includes a Button in the ControlTemplate that the user can click on and it clears the ListBox selection. I dont want to use codebehind so that this Style can be applied to any ListBox . I have tried using EventTrigger s and Storyboard s and it has proved problematic as it only works first time and stopping the Storyboard sets the previous selection back. I know I could use a user control but I want to know if it is possible to achieve this using only a Style . It is not possible to achieve this using XAML and only the classes provided by the .NET

listbox with checkboxes

匆匆过客 提交于 2019-12-04 19:53:44
Greetings, in my asp.net mvc application I have a listbox rendered as follows: <%= Html.ListBox("localization", (Model as SeekWeb.Models.CreateMessageViewModel).Localizations.AsEnumerable())%> is there any way to have checkbox for each listbox item? if checkbox is checked then the appropriate listbox item is selected. Charlino I use a funky little jQuery plugin - jQuery Multiselect - to turn listboxes into more user friendly checkboxes. It's themeroller ready too! Yeah, it does rely on the user having JS enabled but it does degrade gracefully to the standard listbox. HTHs, Charles Checkboxes

List Box Style in a particular item (option) HTML

爷,独闯天下 提交于 2019-12-04 19:35:19
I'm trying to make this behavior. When a have a listBox (or comboBox), my first element (something like "choose one") should have a particular style. With this (test) code: <style type="text/css"> .testX {font-style: italic;} </style> (...) <select name="name" id="id"> <option class="testeX" selected="selected" value="#"> <p class="testX">Choose One</p> </option> <option value="TestValue"> TestValue </option> i can see this behavior on Firefox (but not in Chrome) when i expand my listBox but when i select my 'Choose one' my field doesn't have the (italic) style. How can i do this? Is possible

C# ListBox ObservableCollection<T>

大兔子大兔子 提交于 2019-12-04 18:45:18
问题 I'm trying to use a ListBox.DataSource = ObservableCollection, however I can't figure out how to have the listbox automatically update when my OC updates. I can hook the CollectionChanged event on the OC, however what do I need to do to the listbox to make it update? 回答1: Based on your question, it sounds like you're trying to use ObservableCollection<T> in a WinForms application. ObservableCollection<T> is primarily used in WPF development. In WinForms, for the control be automatically

WPF Listbox Wrapping

回眸只為那壹抹淺笑 提交于 2019-12-04 18:35:38
问题 I have a listbox in which I use a ListBox.ItemsPanel - WrapPanel. <ListBox ItemsSource="{Binding Path=Applets}" Margin="10,92,10,10" ScrollViewer.HorizontalScrollBarVisibility="Disabled" > <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel Orientation="Vertical" IsItemsHost="True"> </WrapPanel> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemTemplate>... I am trying to have the wrappanel have a behavior such that the items fill in to the right as the width is made wider and wrap as

Calculating number of visible items in ListBox

别等时光非礼了梦想. 提交于 2019-12-04 17:56:16
I have a class called Book; class Book { public string Name { get; set; } public string Author { get; set; } public int PagesCount { get; set; } public int Category { get; set; } } The ListBox displays a list of Books and the ItemTemplate has been modified so as to visually represent the Book. The text shows the book's Name, author and the number of pages. The category, however is represented by a certain color (for example, history is blue, romance is red etc.) Now, the text has an OuterGlowBitmap Effect and a value converter from the Category (int) to the appropriate Color. Everything is