listbox

C# adding click events to a list box

拈花ヽ惹草 提交于 2019-12-14 03:54:18
问题 I'm trying to add a click event to a list box but for some reason nothing happens when I click an item in my list box. My guess and from what I've read, the code should look something like this private void listBox1_Click(object sender, EventArgs e) { //Code Ex. TextBox1.Text = "Success"; } That's not working though. Anyone know how to get this to happen? Wouldn't mind knowing the double click and other click variations too.... 回答1: If you want it to trigger when you 'click an item' in the

ListBox in Grid Row with Auto height. Scrollbar is not working

冷暖自知 提交于 2019-12-14 03:53:06
问题 I have the following grid: <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Border Height="50" Background="Gainsboro" Grid.Row="0"/> <Border Background="AliceBlue" Grid.Row="1"> <ListBox ScrollViewer.VerticalScrollBarVisibility="Auto" ItemsSource="asdasdfasdf3dfasdf"/> </Border> <Border Height="60" Background="Aquamarine" Grid.Row="3"/> </Grid> Why ListBox's

Only Enable the last Remove Element Button of a ListBox [duplicate]

寵の児 提交于 2019-12-14 03:36:44
问题 This question already has answers here : XPath : Bind to last item of collection (2 answers) Closed 3 years ago . In my ListBox.ItemTemplate i have a TextBlock and a Remove button, the button must be enabled only if it's the last element o the listbox. 回答1: Created a quick example for you. since you are want to use Button Control you can use Command to enable or disable your button. View: <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml

Accessing Forms data from another form

◇◆丶佛笑我妖孽 提交于 2019-12-14 03:27:58
问题 "Give the code below, how would I access the listBox1 in Form2? I'm sure I'm missing stupid! Thanks in advance." Error 1 'WindowsFormsApplication1.Form2.listBox1' is inaccessible due to its protection level C:\Users\dugaj0\Desktop\Developing\GlobalUser\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs 24 19 WindowsFormsApplication1 using System; using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq;

How to enable a button if an item in a listbox is selected

怎甘沉沦 提交于 2019-12-14 03:18:24
问题 I tried this but it doesn't work. They're still greyed out even when I select stuff. btnVoirFiche.Enabled = false; btnEchangerJoueur.Enabled = false; if (lstJoueurs.SelectedIndex != -1) { btnVoirFiche.Enabled = true; btnEchangerJoueur.Enabled = true; } else { } 回答1: You'll want to handle the ListBox.SelectedIndexChanged event, and within your handler you're going to check if the specific value is the selected one, and then set you button's enable property accordingly. Something like this:

How to bind to a ListBox in a ViewModel

南笙酒味 提交于 2019-12-14 03:17:59
问题 Here's the deal: I have to take a SelectedItem from a Listbox , that I got from this question and add it to a ListBox in another UserControl. The ViewModels and models are all setup, I just need to know how to refer to the ListBox that is getting the items. This would be under ViewModel A -- the ViewModel that controls the user control with the ListBox that receives the items. //This is located in ViewModelA private void buttonClick_Command() { //ListBoxA.Items.Add(ViewModelB ->

adding a header to a listbox's scrollviewer and keeping the virtualizingStackPanel (wp7)

帅比萌擦擦* 提交于 2019-12-14 01:28:59
问题 I want to add a header to my ListBoxes and I do this by using a template. The problem is that if I extend the ListBox's template it seems that the listbox's virtualizingstackpanel doesn't work anymore as expected: it loads all content before I can scroll it. I found some relevant questions in stackoverflow like this (VirtualizingStackPanel stops working when overriding the default control template for ScrollViewer) but the solution given there cannot be applied to WP7: I can't find the

How to create a fast loading wrapping ListBox?

孤街浪徒 提交于 2019-12-14 01:19:11
问题 I've made a nice little three-item wide list of tiles that work as switches. It looks something like this: Looking good huh? Well, I have about 130 of these tiles in a vertically scrolling list, and it takes ages to load. According to the performance analysis tool, each element takes about 18ms to render - which gives me about a 2.3 second rendering time. On the device, it's often twice that time. This wouldn't really be a crisis, but the UI is totally black and unresponsive up until these

WPF live Update from database

随声附和 提交于 2019-12-13 18:15:29
问题 I am building a multiuser WPF application (requirement is a desktop app), database SQL Server 2008. There are two types of users. The first type user will enter a record which would be stored in a table. The second type user initially will be presented with a listbox with the records from the table. The requirement is that the listbox must be updated live (i.e. if a new record is entered by the first user the listbox must be updated). Currently I have not yet implemented the Database

MS Access - Multi Select Listbox to delete records from table

你说的曾经没有我的故事 提交于 2019-12-13 17:53:23
问题 I am using Access 2010 on Windows 8. I was looking for a way to use a multi select listbox to delete several records from a table at once. I came accross this post on StackOverflow and it helped get me started: Delete multiple selected record from a multiselect listbox (Access) I adjusted the code in the solution to work with my tables and objects but for some reason it only works when one record is selected. If I select 2 or more records then nothing happens. Can anyone take a look and help