listbox

get clicked button content from button styled listbox binded to xml

纵然是瞬间 提交于 2019-11-29 12:49:06
Hi I have a listbox binded to a xml file, and each item I gave them a button data template so I can easily register a click event to each item. I would love to get the clicked button's content to do some query on. Here is my code XAML <ListBox Name="listBox1" > <ListBox.ItemsSource> <Binding Source="{StaticResource keywordLib}" XPath="Position/Keyword/Word"/> </ListBox.ItemsSource> <ListBox.ItemTemplate> <DataTemplate> <Button Content="{Binding}" Click="keyword_Click"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> After hours of googling for solutions. I know I should use sender from the

Excel VBA Multicolumn Listbox add non contiguous range

╄→гoц情女王★ 提交于 2019-11-29 12:01:31
Im trying to figure out how to add a non contiguous range of cells in a row to a multicolumn Listbox, but only the second line below works. lbxSelectable.List = Sheets("DB").Range("A1,B1,C1").Value lbxSelectable.List = Sheets("DB").Range("A1:C1").Value Is there any efficient function which will allow me to select certain columns in a row and stick it in an entry of a multicolumn list box? Many thanks To display a non contiguous range of cells in a row to a multicollumn Listbox, you have to first create an Array and then assign it to the .list of the listbox. Here is an example. Option Explicit

LIstbox Selected Item content to textblock

不羁岁月 提交于 2019-11-29 11:59:43
I am sure there is a simple solution to this, but I can't seem to find it at the moment. I am trying to disaply the content of the selection listbox in a textblock as text using the below code. private void SelectionToText(object sender, EventArgs e) { ListBoxItem selection = (ListBoxItem)TextListBox.SelectedItem; selectionText.Text = "This is the " + selection; } For some reason the textblock just displays "This is the System.Windows.Controls.ListBoxItem " I initial thought it was because I hasn't converted to a string, but that didn't work either. Any suggestions? You can reference the

Move items from one listbox to another

本小妞迷上赌 提交于 2019-11-29 11:56:13
I'd like to move items from one list view to another. adding them to the second one works but the moved entries don't get removed at all. private void MoveSelItems(ListBox from, ListBox to) { for (int i = 0; i < from.SelectedItems.Count; i++) { to.Items.Add(from.SelectedItems[i].ToString()); } from.Items.Remove(to.SelectedItem); } I'm using C# / Winforms / -NET 3.5 Try this code instead at the end of the loop foreach ( var item in new ArrayList(from.SelectedItems) ) { from.Items.Remove(item); } private void MoveSelItems(ListBox from, ListBox to) { while (from.SelectedItems.Count > 0) { to

Problem getting list box items added through jquery in code behind

你说的曾经没有我的故事 提交于 2019-11-29 11:47:30
I have a asp.net list box control in which i populate items using Jquery by using some code like .. $("#MylistBox").append("<option value='somevalue'>Someitem</option> dynamically . but in code behind when i use MylistBox.Items is always showing Count 0 no matter how much items add. Can anybody help me with this? Without knowing the actual scenario... I am assuming your goal is actually to get the dynamically added items either by iterating over them or something else... Any dynamically added DOM element that is done on the client side using JavaScript / jQuery, will not be reflected

Get reference to my WPF ListBox's ScrollViewer in C#?

我的未来我决定 提交于 2019-11-29 11:39:18
I think this should be easy but I'm having a tough time with it. How can I get a reference to my ListBox's scrollviewer in C#? I've tried pretty much everything I can think of. The ListBox is in a WPF Custom Control so we use Template.FindName to get references to all our controls. My ListBox looks like this: <ListBox x:Name="PART_SoundList" ScrollViewer.CanContentScroll="False" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Hidden" Focusable="False" FocusVisualStyle="{x:Null}" HorizontalAlignment="Center" VerticalAlignment="Bottom" BorderThickness=

Tabs and colored lines in Listbox

自古美人都是妖i 提交于 2019-11-29 11:36:16
I am using a Tabbed Listbox component that was written by Fredric Rylander back in 1999 and it has been serving me well since then. :) Can't seem to find him anymore. I now have an application that needs both Tabbed Data and alternating colored lines in the Listbox. I can include the Component here for perusal if desired. I tried coloring the lines from here http://delphi.about.com/cs/adptips2002/a/bltip0602_4.htm But then it eats the Tabs, but I do get the alternating colored lines. Can someone please show me how to incorporate the two. Thanks Here's the Component unit myListBoxTabbed; {

WPF Drag & drop from ListBox with SelectionMode Multiple

匆匆过客 提交于 2019-11-29 11:31:20
问题 I've almost got this working apart from one little annoying thing... Because the ListBox selection happens on mouse down, if you start the drag with the mouse down when selecting the last item to drag it works fine, but if you select all the items to drag first and then click on the selection to start dragging it, the one you click on gets unselected and left behind after the drag. Any thoughts on the best way to get around this? <DockPanel LastChildFill="True"> <ListBox ItemsSource="{Binding

ASP.NET: Listbox datasource and databind

纵饮孤独 提交于 2019-11-29 11:29:40
I have an empty listbox on .aspx page lstbx_confiredLevel1List I am generating two lists programatically List<String> l1ListText = new List<string>(); //holds the text List<String> l1ListValue = new List<string>();//holds the value linked to the text I want to load lstbx_confiredLevel1List list box on .aspx page with above values and text. So i am doing following: lstbx_confiredLevel1List.DataSource = l1ListText; lstbx_confiredLevel1List.DataTextField = l1ListText.ToString(); lstbx_confiredLevel1List.DataValueField = l1ListValue.ToString(); lstbx_confiredLevel1List.DataBind(); but it does not

Add a Load More Button at the end of ListBox without losing Virtualization?

眉间皱痕 提交于 2019-11-29 11:23:20
I know by editing the ListBox 's default style like this, I can have a Button at the very end of the ListBox . <ScrollViewer x:Name="ScrollViewer" ...> <StackPanel> <ItemsPresenter /> <Button /> </StackPanel> </ScrollViewer> However, doing this will break the ListBox 's Virtualization and the rendering time becomes really long. All I can think of is, Create a dummy item and add it to the end of my item collection in the viewmodel, and have a Visibility property in the dummy object called ButtonGridVisibility and set it to Visibility.Visible . In my ListBox 's ItemTemplate , have two Grids .