listbox

ListBox DrawItem HotLight State in the OwnerDraw mode?

假装没事ソ 提交于 2019-12-04 03:15:31
问题 I'm using OwnerDrawFixed as a DrawMode for the custom ListBox control in my WinForms app. I want to repaint the background (or do some other action) of the ListBoxItem when the user hovers over the listbox item, that is, at the MouseMove... DrawItemState.HotLight never works for the ListBox, so i wonder how to emulate it, how to workaround this problem. 回答1: It took me only two years to find the answer for you, but here it is: The DrawItemState.HotLight only applies to owner drawn menus, not

Remove Extra Space around Listbox

邮差的信 提交于 2019-12-04 03:01:49
问题 I have some extra space around my Listbox. It's 1px wide, but I don't know where it comes from... I set the padding, margin and BorderThickness of both, the ListBox and the ListboxItem to 0. This is the XAML: <!-- NOTEBOX LISTBOX --> <!-- The Datatemplate for the Notebox - ListboxItem --> <DataTemplate x:Key="NoteListboxItemTemplate" DataType="ListBoxItem"> <Border Style="{DynamicResource OuterNoteBoxBorder}"> <Border Style="{DynamicResource SecondOuterNoteBoxBorder}"> <StackPanel> <TextBlock

GWT ListBox - how to have a listbox item disabled?

白昼怎懂夜的黑 提交于 2019-12-04 02:44:53
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 You could select the first child element and set the disabled atribute: list.getElement().getFirstChildElement().setAttribute("disabled", "disabled"); KFox112 For anyone who finds this page and is looking to disable a GWT ListBox option which is NOT the first option in the ListBox, this worked for me: list.getElement().getElementsByTagName("option"

C# Listbox.DrawItem to color each lines

蹲街弑〆低调 提交于 2019-12-04 02:21:52
问题 I have some code to change how listbox act. I can change the color of text, but I am unable to change the color of the background of each line. This is in a for loop for every of my lines LBLines is an array of string store in a global variable if (LBLines[e.Index] != "None") { e.Graphics.FillRectangle(new SolidBrush(Color.FromName(LBLines[e.Index])), e.Bounds.X,e.Bounds.Y,e.Bounds.Width,e.Bounds.Height); } This will color EVERY lines of the same color, even those listed as "None", thou what

Delphi FireMonkey TListBox AddObject exception on Android

为君一笑 提交于 2019-12-04 02:01:43
问题 I'm having a problem adding a TObject value to a FireMonkey TListBox in Delphi 10.0 Seattle. An exeception is raised when casting an Integer variable to a TObject pointer. I tried the cast to TFmxObject with no success. On Windows, the cast works like a charm, but on Android it raises the exception. Here is my code: var jValue:TJSONValue; i,total,id: integer; date: string; begin while (i < total) do begin date := converteDate(jValue.GetValue('date' + IntToStr(i), '')); id := StrToInt(jValue

ListBox margin is not the same in Windows 7 and Windows 8

江枫思渺然 提交于 2019-12-04 01:43:13
I have styled an WPF ListBox. I'm developing under Windows 8. After setup the style to be as follows (see image), when I test the application in Windows 7, the margin is not the same. As you can see in the imagen the separation between nodes is 1px in Windows 8, but 0 px in Windows 7. Do you know why is this, and how to solve it? Thanks in advance. I actually managed to get rid of it myself, it looks like it's ListViewItem style that's being changed by Windows8, adding a style to the local resources of the ListView has worked for me. <ListView.Resources> <Style TargetType="ListViewItem">

customize the Border property with CornerRadius for ListBox

隐身守侯 提交于 2019-12-04 00:47:49
问题 I want to customize the following Listbox-display property of border with CornerRadius=5..can anyone help me to achieve it without changing the existing datatemplate code in the following Xaml code: <ListBox x:Uid="lst_value" Name="lstValues" Background="Wheat" BorderBrush="Black" HorizontalAlignment="Left" VerticalAlignment="Top" BorderThickness="1" Height="100" Width="150" ItemsSource="{Binding listval}" > <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Vertical" Background="

Programmatically selecting Items/Indexes in a ListBox

独自空忆成欢 提交于 2019-12-04 00:14:59
问题 In WPF, I'd like to set the selected indexes of a System.Windows.Controls.ListBox I best way I've found so far is to remove all the items from the control, insert the selected, call SelectAll(), then insert the rest, but this solution neither works in my situation nor is very efficient. So, how do you set items in a Listbox to be selected, programmatically? 回答1: One way you can do this is to add a Selected field to your data object. Then you need to overide the default listboxitem style and

WPF - reset ListBox scroll position when ItemsSource changes

偶尔善良 提交于 2019-12-03 22:52:40
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, until the 1 item comes into view. So, what I think I'm after, is a way of resetting the scroll position

ListBox mouse over background color

只谈情不闲聊 提交于 2019-12-03 22:44:29
问题 The problem I have is the MouseOver trigger to color the background fails on the selected row. For any non-selected row the background turns blue on mouse over. But no blue background for the selected row. Click on a row and then the background blue goes away. I also tried the style in the ListBox.ItemContainerStyle <Window x:Class="ListBoxLastIntoView.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title=