listboxitem

WPF ListBoxItem events never called

戏子无情 提交于 2019-12-11 16:42:36
问题 I want to trigger events on a ListBoxItem <ListBox.ItemTemplate> <DataTemplate> </DataTemplate> </ListBox.ItemTemplate> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <EventSetter Event="Drop" Handler="Item_Drop"/> <EventSetter Event="PreviewMouseLeftButtonDown" Handler="Item_PreviewMouseLeftButtonDown" /> </Style> </ListBox.ItemContainerStyle> </ListBox> In Code behind, there are the two eventhandlers private void Item_Drop(object sender, DragEventArgs e) { } private void Item

Why are my TListBox items not changing their color?

为君一笑 提交于 2019-12-11 10:05:17
问题 This is how I'm getting a few items from a List located on a local server. I assume it still need some refactoring (sorry for being such a beginner in Delphi ), however I would like to understand better why the ListItem colors are not being changed. I did some debugging and found out that the if conditions are working fine for each color, and the ListItem is receiving it but I might be getting the wrong reference or using the wrong property to change the color. Here's the full code: procedure

ListBoxItem HorizontalContentAlignment=Stretch not working

左心房为你撑大大i 提交于 2019-12-11 06:46:52
问题 I am having trouble getting my listbox items to stretch to the whole listbox width. Below is my xaml for my listbox <ListBox x:Name="MyListBox" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" HorizontalContentAlignment = "Stretch" Margin="0,10,0,0" ItemsSource="{Binding Path=Users}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="1" Grid.RowSpan="3"> <ListBox.ItemTemplate> <DataTemplate> <local:MyListBoxTemplate/> </DataTemplate> <

Use a object property as the DisplayMember in ListBox

走远了吗. 提交于 2019-12-11 05:16:30
问题 I want to use a property of an object that's inside an object. Is there a way to achieve this? WebProxy proxy = new WebProxy("127.0.0.1:80"); ListBox listBox = new ListBox(); listBox.DisplayMember = **"Address.Authority"**; //Note: Address.Authority is an property inside the WebProxy object listBox.Items.Add(proxy); Thanks. 回答1: Have a look at this question, it is essentially asking the same thing - the principle does not change between DataGridView and ListBox . Short answer: it's possible,

VBA Removing ListBox Duplicates

不想你离开。 提交于 2019-12-11 05:03:35
问题 I'm trying to add a list of names from another worksheet that has duplicates. On the listbox, I want to have unique names, instead of duplicates. The following code is not sorting them for duplicates, it errors out. Any help is appreciated. Dim intCount As Integer Dim rngData As Range Dim strID As String Dim rngCell As Range dim ctrlListNames as MSForms.ListBox Set rngData = Application.ThisWorkbook.Worksheets("Names").Range("A").CurrentRegion 'declare header of strID and sort it strID =

In WPF code-behind, how do I set the background color for each individual ListBoxItem where the color is based on the item itself?

故事扮演 提交于 2019-12-11 04:09:22
问题 My end goal is to have a ListBox show me a list of colors, where the value of the background color is the color itself. Eventually, this ListBox will load a previously saved collection of colors, but for now I'm just trying to get it to work with dummy data - a dictionary I filled up using the colors from System.Windows.Media.Colors ( <string, Color> , where string is the friendly name and Color is a custom class that only contains the Red , Green , Blue , and Hex values for the color). It's

ListBox Selected Item Style for Windows Phone 8.1

不问归期 提交于 2019-12-11 00:41:01
问题 I have a simple listbox and I would like to change the Style so that when an item is selected, the border of the item changes colour. Currently my ListBox and style is defined as: <ListBox x:Name="DaysList" HorizontalContentAlignment="Stretch" Background="Transparent" Height="300" Grid.Row="1" > <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter> <Setter Property="FontSize" Value="30" /> <Setter Property=

select all items in the listbox in asp.net

自古美人都是妖i 提交于 2019-12-10 22:34:13
问题 if checkbox is clicked i need to select all items in the listbox in asp.net... how to show the items all selected in listbox once the 'selectall' checkbox is clicked 回答1: In the CheckedChanged event handler of the checkbox, iterate through all the items of the list and set the Selected property for all as true. You also need to make sure that the multi selection is enabled on your listbox. Use the following to do that: ... for(int i=0;i<ListBox1.Items.Count;i++) { ListBox1.Items[i].Selected =

how is the foreground color changed on just one line of wpf listbox?

六眼飞鱼酱① 提交于 2019-12-10 17:42:11
问题 how is the foreground text color changed (not the selected text, or the background of the selection) in a wpf listbox? say, for example, i wanted to make all the letter "a" items green, all the letter "b" items red, etc? how can i programmatically do that as i add them in c#? all i can find is people posting about changing selected text, i want to change the color of the foreground text to make it look more organized . on a side note, why is stackoverflow giving me problems about this

How can I add a ListBoxItem programmatically?

雨燕双飞 提交于 2019-12-08 10:40:13
问题 I could only find how to create a ListBoxItem by clicking on the component -> Items Editor . How can we create programmatically a ListBoxItem using Firemonkey ? 回答1: Assuming that a ListBoxItem is an item of an existing TListBox component named ListBox1 , the item can be added like this: ListBox1.Items.Add('an item name'); an alternative: var id: Integer; . . . ListBox1.Items.AddObject('an item name', TObject(id)); EDIT Notice that this approach has to be considered valid only if the