listbox

Reset listbox selection in VBA

狂风中的少年 提交于 2019-12-01 21:33:53
问题 I'm trying to 'reset' a listbox in Excel VBA when a form closes. Currently when I use the userform1.hide function the form disappears but when I open it up again using the .show function it still has the previous selections in it. As someone who is relatively new to this can anyone help? The code for the listboxes is as follows: Sub CommandButton1_Click() 'Filter by Country Dim item As Long, dict As Object Dim wsData As Worksheet Set wsData = Sheets("TPID") Set dict = CreateObject("Scripting

Windows Phone Mango - ListBox or LongListSelector?

ぃ、小莉子 提交于 2019-12-01 21:06:13
问题 Say if I need to display a list with lots and lots of records, which control is better? Or shall I say, which control has a better scrolling experience? I've seen a lot of people reporting issues on this LongListSelector, is it really too buggy to use? Hope someone can shed some light on this for me. Thanks in adv. Xin 回答1: If you don't need grouping, I wouldn't use the LongListSelector. The virtualization support is easier to use/manage with a regular ListBox. And as of Mango, the ListBox

Preventing ListBox scrolling to top when updated

纵饮孤独 提交于 2019-12-01 20:53:28
问题 I'm trying to build a simple music player with a ListBox playlist. When adding audio files to the playlist, it first fills the ListBox with the filenames and then (on a separate thread) extracts the ID3 data and overwrites the filenames with the correct Artist - Title information (much like Winamp). But while the ListBox is being updated, it's unscrollable, as it always jumps to the top on every item overwrite. Any way to prevent this? EDIT: The code: public Form1() { //Some initialization

WPF: Listbox, centering selected item

爱⌒轻易说出口 提交于 2019-12-01 20:33:12
Is it possible to always keep selected item in the middle of a listbox? If the user selects an item, I want to scroll so that the newly selected item is in the middle. I guess it want be possible for the 'edge cases' (the first and last few items), but that's ok. David Anson posted some articles on his blog that might help you here: Part 1 and Part 2 . He gives an extension method that centers an item in an List Box. You might be able to build on that. It is possible with couple of lines of custom code. Here's a discussion of a sample implementation . You might need to tweak it a bit to

Change disabled listbox background to gray

孤街醉人 提交于 2019-12-01 20:09:54
I have a ListBox which I need to gray out when it's disabled. Per user request it's not enough to disable it, but it also has to appear differently. shrugs I've looked in several other places and followed the examples, and it seems as if it should work, but it does not. Here are some examples I looked at: Example1 , Example2 . Here is my code: <Style x:Key="ListBoxStyle" TargetType="ListBox"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBox}"> <ControlTemplate.Triggers> <Trigger Property="IsEnabled" Value="False"> <Setter Property="BorderBrush" Value=

Preventing ListBox scrolling to top when updated

帅比萌擦擦* 提交于 2019-12-01 20:09:44
I'm trying to build a simple music player with a ListBox playlist. When adding audio files to the playlist, it first fills the ListBox with the filenames and then (on a separate thread) extracts the ID3 data and overwrites the filenames with the correct Artist - Title information (much like Winamp). But while the ListBox is being updated, it's unscrollable, as it always jumps to the top on every item overwrite. Any way to prevent this? EDIT: The code: public Form1() { //Some initialization code omitted here BindingList<TAG_INFO> trackList = new BindingList<TAG_INFO>(); // The Playlist this

Set the font and color of a listbox item by code in C#

廉价感情. 提交于 2019-12-01 19:30:42
问题 I'm busy with a customized list box that I use as a register reader in c#. Now I want to set a determined item in a determined item with a different font and color than the rest. I checked This question and from the answers I made the following code: private void myListBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { e.DrawBackground(); Font myFont; Brush myBrush; int i = e.Index; if (e.Index == 3) { myFont = e.Font; myBrush = Brushes.Black; } else { myFont = new Font(

ListBox Shift-Click Multi-Select Anchor is not being set properly

守給你的承諾、 提交于 2019-12-01 19:07:30
I’m at my wit’s end trying to figure this out. I'm experienced in WPF, but I've never seen anything like this. I have a ListBox that contains selectable ListBoxItems. Items in the list can be selected by mouse click or by using the up/down arrows. I’m using SelectionMode.Extended, so my list supports multiple selections. The problem: Clicking on an item in the list, then Shift-Clicking on another item selects the correct range of items like you would expect. Unfortunately, using the up/down arrows does not work properly – instead, the range that’s selected always seems to be based off of the

Set the font and color of a listbox item by code in C#

谁都会走 提交于 2019-12-01 18:50:41
I'm busy with a customized list box that I use as a register reader in c#. Now I want to set a determined item in a determined item with a different font and color than the rest. I checked This question and from the answers I made the following code: private void myListBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { e.DrawBackground(); Font myFont; Brush myBrush; int i = e.Index; if (e.Index == 3) { myFont = e.Font; myBrush = Brushes.Black; } else { myFont = new Font("Microsoft Sans Serif", 9.75f, FontStyle.Bold); myBrush = Brushes.CadetBlue; } e.Graphics.DrawString

How to show a divider between items in a ListBox?

筅森魡賤 提交于 2019-12-01 18:46:32
I am using a ListBox control in a Windows Phone 7 application, and I would like to show a divider/line between the list rows. I have not been able to find any information about this, although many (not wp7) ListBox examples seem to have a divider. Got inspired by NestorArturo and found out about the Border control. It is very easy to wrap your ItemTemplate content in a Border control and specify the BorderThickness and BorderBrush. I went this way, because it doesn't require changes to my Grid in the ItemTemplate. The Border control is described here: http://www.silverlightshow.net/items/Using