listbox

Change how items are displayed WPF list box

空扰寡人 提交于 2019-12-10 09:44:16
问题 I have a WPF window which displays a ListBox . I've changed the ListBox 's item template so that the list box displays rectangular items which can be selected. Now I'd like to modify the ListBox 's ItemsPanelTemplate so that the items are displayed in a grid instead of either a vertical or horizontal list. Specifically I'd like the first item to go in the top right corner of the ListBox and then second item below it and third under that until the height of the next item would make the column

ListBox created with WinAPI in VBA doesn't work

一曲冷凌霜 提交于 2019-12-10 03:05:49
问题 I want to create a ListBox in VBA with WinAPI. I managed to create it, but ListBox doesn't respond to actions - no scrolling, no selecting. None of this works. It looks like it's disabled. How to make it respond to actions? The following code was used to create and fill ListBox . WinAPI functions Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Declare Function CreateWindow Lib "user32.dll" Alias

List Box Style in a particular item (option) HTML

孤人 提交于 2019-12-09 23:44:42
问题 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

Getting all the items from the listbox winform

冷暖自知 提交于 2019-12-09 21:54:50
问题 Good day! I am having troubles on getting all the items, selected or not, from the listbox. Whenever I click the send button, the only items that I could get is the ones I selected (This is the current results of my code below: http://imgur.com/jA94Bjm). What I want is to get all the items from the textbox not just from the selected ones and which is not repeating. private void cmd_send_Click_1(object sender, EventArgs e) { for (int i = 0; i < listBox1.Items.Count; i++) { try { String pno =

Prevent WPF ListBox from selecting item under mouse when layout changes

末鹿安然 提交于 2019-12-09 18:38:32
问题 If a WPF ListBox gets a MouseMove event while the mouse button is held down, it will change the listbox's selection. That is, if you click the mouse on item #1, and then drag over item #2, it will deselect item #1 and select item #2 instead. How can I prevent this? That's the short version. The slightly longer version is this: When the user double-clicks an item in my ListBox, I make other changes to my layout, which includes showing other controls above the ListBox. This moves the ListBox

WPF - Why Listbox items do not fill uniformgrid

淺唱寂寞╮ 提交于 2019-12-09 18:34:22
问题 I have a listbox with the ItemsPanelTemplate set to UniformGrid with rows= 6 and cols= 7. I want the listbox items to fill their space. I am using a datatemplete defined in a dictionary. The outer control of my template is a Border with HorizontalAlignment=Stretch and VerticalAlignent=Strectch but the templates do not fill the listbox items space? Any ideas? Malcolm 回答1: The answer to this to set HorizontalContentAligment and VerticalContentAlignment to Stretch on the LISTBOX not the

Listbox datatemplate - item only selectable by clicking a subelement, not just anywhere on the item

不羁岁月 提交于 2019-12-09 16:48:10
问题 I have a listbox with a datatemplate for the items. The problem is that selecting an item doesn't work by just clicking anywhere on the item; I have to click on a specific sub-element for it to actually work. My item has an image and a textblock. If I hover the mouse over the image or text-block, I actually see the hover-effect. If I hover the mouse over any of the 'empty' space of the item, no hover effect (and no selection when I click there). Example image : http://i33.tinypic.com/wvtleg

WPF - reset ListBox scroll position when ItemsSource changes

╄→尐↘猪︶ㄣ 提交于 2019-12-09 14:10:57
问题 I currently have a ListBox whose ItemsSource collection is bound to a property on my viewmodel, of type IEnumerable. When that preoprty's reference changes, the ListBox updates as expected, however I have a problem in that if I have a large collection of items and scroll to the bottom of the ListBox, and then change the reference to another collection containing, say, 1 item, the ListBox view is blank and no scrollbar is displayed. I have to then scroll the listbox up with the mouse wheel,

How to get listbox selected item value

左心房为你撑大大i 提交于 2019-12-09 13:05:19
问题 I am working with C# .NET 4.0 I am trying to get the value of a single selected item in a listbox. This is how I populate the control: this.files_lb.DataSource = DataTable object In my designer, I have specified file_name as the DisplayMember and file_id as the DisplayValue After selecting an item in the listbox, I tried the following to get the value: this.files_lb.SelectedValue.ToString() But all it returns is "System.Data.DataRowView". At this link : Getting value of selected item in list

How do you access the ScrollViewer element of a ListBox control in Silverlight/C#?

妖精的绣舞 提交于 2019-12-09 12:31:55
问题 I wish to dynamically change the scroll position of a Silverlight ListBox from C#, and I need to know how to access the ScrollViewer element of a ListBox control from C#? Thanks guys, Jeff 回答1: From within a class that inherits from the ListBox class, you can use the Protected GetTemplateChild(): var myScrollviewer = myListBox.GetTemplateChild("ScrollViewer") as ScrollViewer; If you want to access this from outside the ListBox, then exposing the ScrollViewer via a Property should work, again