FAQ Database Discussion Community


invalidcastexception when trying to convert from ListBox object to MyListBox : ListBox object in WPF

c#,wpf,xaml,listbox
I use a ListBox in my code to store some csv files selected by the user: <ListBox x:Name="emailsFilesListBox" HorizontalAlignment="Left" Height="67" Margin="10,254,0,0" Grid.Row="1" VerticalAlignment="Top" Width="147"/> In MainWindow.xaml.cs I use a private class to extend System.Windows.Controls.ListBox: private class MyListBox : System.Windows.Controls.ListBox { public string[] FullFilesPathsList { get; set; } public MyListBox() :...

VBA - Adding a listbox to an array

arrays,vba,listbox,userform
I've been searching around online, and just want to know how to add a bunch of ListBoxes from my Userform to my array. Here's what I have so far: Dim LBArray() As Variant Private Sub UserForm_Initialize() ReDim LBArray(7) As Variant FirstNameTextBox.Clear LastNameTextBox.Clear HotelCIDate.Clear HotelCODate.Clear HotelNameBox.Clear HotelConfStatus.Clear HotelConfNumber.Clear LBArray(0) = FirstNameTextBox...

reference dictionary within array output to listbox

arrays,vb.net,dictionary,listbox
Title kind of states my problem. I'm using an Api (For Vertical Response, an email list manager) which works fine. But for a particular method returns an Array where the information I need to reference is within a Dictionary inside that Array. Array[list_id, list_name, list_type, member_data] <- member_data being the...

Delphi, Lazarus - Listbox out of bound (0) TString

delphi,listbox,indexoutofboundsexception,lazarus,tstringlist
I simply can't seem to make any sense of the following error. Listbox out of bound (0) TString I have a form or window with a listbox and following code is supposed to work with it. It suppose to get a list of strings from an ini file and set...

WPF Interactions CallMethodAction for DataTemplate in ListCheckBox thrown a exception “Could not find method on object of type”

c#,wpf,xaml,checkbox,listbox
I'm trying to use interactions, but I can't write ordered params in my method in ViewModel. I'm use a ListBox who have items inner a checkbox and another controls. So I trying to use the different combinations of params TargetObject of CallMathodAction in my usercontrol, but I can't get the...

Images aren't displayed in WPF ListBox

wpf,data-binding,listbox
I'm trying to display images in a ListView. The images are being loaded through Entity Framework from a SQL Server database. Somehow the images don't get displayed in the ListView and I can't figure out why. I've created a test Visual Studio project. The images are stored in an ObservableCollection<ImageViewModel>:...

Why cant select variables from listbox like this in VBA?

excel,vba,excel-vba,for-loop,listbox
Hey guys I want to select some variable from the "Variable(s)" listbox to the "Row" and/or "Column" listbox. I know I should write like this: For irow = lbxVar.ListCount To 1 Step -1 If lbxVar.Selected(irow - 1) = True Then lbxColumn.AddItem lbxVar.List(irow - 1) lbxVar.RemoveItem (irow - 1) End If...

WPF Listbox Collection custom sort

wpf,sorting,listbox,compare,collectionview
I have a listbox DropPrice MyPrice Price1 Price2 I want to sort it like this Price1 Price2 DropPrice MyPrice I mean, if there's an item that starts with the sequence "price", it gets priority, else the smallest string should get the priority. My source code: var lcv = (ListCollectionView)(CollectionViewSource.GetDefaultView(_itemsSource)); var...

Doing the maths of numbers in a listbox based on the first character of each item

c#,math,textbox,listbox
I have a program that adds items to a list box. The items consist of a character (+,-,*,/) followed by numbers. I want to get my program to recognize the first character of the item in the list box, and do the math appropriately. However, I cannot seem to get...

ListBox specific row/item coloring Diffrent Color C# wpf

c#,wpf,xaml,listbox,background-color
I need to Mark the first item in the ListBox in a different way like in a different color. if i have listbox is there a way to color the first item in it Red preferred programmatically. ListBox: List<CartItem> CartListItem = CartItem.getListOfCartItems(myCart, Items); dgProduct.ItemsSource = Items; Xaml <ListBox Name="dgProduct" HorizontalContentAlignment="Stretch"...

how can i get the value of index in listbox?

c#,vb.net,listbox
I am writing a c# windows form application program on vb. I have a listbox and when I double-click on any data it is removed but before delete it I want to keep the data in a string or integer. How can i do that? Here is my code to...

How to make a Listbox limits to 3 column in Tkinter?

python,tkinter,listbox
Basically, I created a Listbox to record Lab Time for racing purpose. Whenever the car finishes a lap, I hit a Button to record the Lap time. In my scenario, I only want to record 3 Laps. (Meaning when I press the button 3 times, it will record all the...

c# adding or deleting data in listbox

c#,listbox
I have a program and i want to remove the data when i click double to any data. How can i do that? This is the part of my code: this.listBox1.MouseDoubleClick += new MouseEventHandler(listBox1_MouseDoubleClick); void listBox1_MouseDoubleClick(object sender, MouseEventArgs e) { int index = this.listBox1.IndexFromPoint(e.Location); if (index != System.Windows.Forms.ListBox.NoMatches) { MessageBox.Show(index.ToString());...

Access VBA How can I filter a recordset based on the selections in a multi select list box?

vba,ms-access,listbox,openform
I am trying to use the OpenForm function to filter based on the selections in a multi select list box. what is the correct syntax for this, or is there a better way to go about it? For the sake of example let's say: List Box has options Ken, Mike,...

javascript unable to set property selectindex list box

javascript,asp.net,listbox,selectedindex
I have a list box which is binding in code behind, the user can select from the list and submit. The error that is occurring in the link button which clear this list from selecting is unable to set property 'selectedindex' of undefined or null reference ASP.NET: <asp:ListBox ID="lstBoxAgents" runat="server"...

How to respond a mouse message about right-button in listbox item?

c,winapi,listbox,right-click
If i use the win32 api,how to respond WM_RBUTTONUP? case WM_RBUTTONUP: { break; } case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch (wmId) { case IDE_FRIEND: { switch (wmEvent) { case WM_RBUTTONUP: { POINT pt; GetCursorPos(&pt); TrackPopupMenu(g_hMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hWnd, nullptr); break; } default: return DefWindowProc(hWnd, msg,...

c# How to sort an array and put in a listbox?

c#,sorting,listbox
I am new to C# and I am trying to sort numbers from lowest to highest and then put them inside a ListBox. What I did so far is: { int[] sortArray = new int[listBox2.Items.Count]; for (int i = 0; i < listBox2.Items.Count; i++) { string sort = listBox2.GetItemText(i); sortArray[i]...

getting listbox.selectedindex by clicking on checkbox

c#,wpf,checkbox,listbox,wpf-controls
this is my user template in listbox. i want to have "listbox.selectedindex" on clicking any checkbox of listbox. i want to knw of which row,checkbox is selected.like on click event of checkbox,it should focus the whole selected row. <ListView x:Name="listbox3" Visibility="Visible" Margin="540,168,37,46" IsSynchronizedWithCurrentItem="True" BorderBrush="Black"> <ListView.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Width="200" >...

tkinter: progress list not updating

osx,python-2.7,user-interface,tkinter,listbox
I have great difficulty boiling down my problem into a fundamental one, so my apologies if this is already treated in another question. My problem lies in providing progress feedback to the user. The basic system is used to import files, analyze them (with an external function) and in the...

How to enable or disable menu items based on SelectedItems in ListBox

c#,wpf,listbox,contextmenu
Is there a way to do this when the ContextMenu itself is defined inside the ListBox? I have my ListBox set up like this: <ListBox Name="lbxFoundFiles" Margin="10,115,10,5" SelectionMode="Multiple" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" ItemsSource="{Binding FoundFilesInfo}" ItemTemplate="{DynamicResource FoundFilesListItem}"> <ListBox.ContextMenu> <ContextMenu> <MenuItem Name="cmiCopyClipboard" Header="Copy file to clipboard" Click="cmiCopyClipboard_Click" IsEnabled="{Binding...

WPF : How to bind Button's visibility inside ListBox ItemsControl using selecteditem information ?

c#,wpf,listbox,itemscontrol,selecteditem
I have a list box binds to a ObservableCollection of Items. Each listboxItem contains a few textblocks and a few buttons. I would like to show the buttons inside the listboxItem only when the listbox item is selected or hightlight. If the listbox item is not highlighted, the button should...

Storing Individual Values From List Box As Variables

c#,listbox,sqlconnection
I have a listbox which is currently reading fields from my database. I would like to be able to store each individual values that I am reading in as strings and ints. There will four field types, these are Surname, Forename, EmployeeID, PaymentDate. How do I split and store the...

how can i make a loop of data having in listbox in vb?

vb.net,listbox
i have a listbox having value of integer . i want to make 2 loop Do While objReader.Peek() <> -1 TextLine = objReader.ReadLine() words = TextLine.Split(New Char() {","c}) ListBox1.Items.Add(words(3) & "," & words(4)) Loop For i As Integer = 0 To ListBox1.Items.Count - 1 Dim tempstr = ListBox1.Items.Item(i) tempstr =...

How to bind selectedItem from different listboxes to one textbox?

c#,wpf,xaml,binding,listbox
I am very new to WPF and I got stuck with a binding problem. I have 3 listboxes that I want to bind to one textbox. In listbox1 I have the name "John Doe", in listbox2 "Brian Warner" and in listbox3 "Anne Brown". When I click on "John Doe" it...

Getting selected items from a listbox using the index instead of value

c#,listbox,code-behind
When I fill a listbox, I do something like this: SqlDataAdapter adapter = new SqlDataAdapter("Select [DDLValue], [StoredValue] from [tmpDropdowns] WHERE DDLName = 'ddlHobbies' ORDER BY [SortOrder] ASC", conn); adapter.Fill(DDLHobbies); Hobbies.DataSource = DDLHobbies; Hobbies.DataTextField = "DDLValue"; Hobbies.DataValueField = "StoredValue"; Hobbies.DataBind(); And when I want to retrieve the items, I do something...

MouseRightClick on ListBox crashes the app

c#,wpf,listbox
When I do the mouse right click on my empty listbox, the whole app just crashes and I don't even know how to debug this, where to put try-catch and so on. Have anybody encountered such problem? Any ideas on how to solve that issue? Here's my XAML on the...

How can I add string value and integer value into listbox in vb.net?

vb.net,listbox
I'm beginner for vb.net.I try to add string value and integer value into listbox but it throw invalid cast exception.I mention code bellow. Public Class frmDetails Private Sub btnCompute_Click(sender As System.Object, e As System.EventArgs) Handles btnCompute.Click Listbox1.Items.Add("sum is " + (3 + 2)) Listbox1.Items.Add("Substract is" + (3 - 2)) Listbox1.Items.Add("Multiplication...

Overridden winform ListBox.Sort() not getting called as expected

c#,winforms,sorting,listbox
I'm trying to override the sort method in a listbox to sort in descending order. Code: public CustomSortListBox() : base() { } protected override void Sort() { if (this.Items.Count > 1) { bool swapped; do { int counter = this.Items.Count - 1; swapped = false; while (counter > 0) {...

Excel VB Listbox losing Value and Text Property

excel,excel-vba,properties,listbox
I'm trying to solve this problem along 2 days but I've not found the solution. I have a lot of listboxes on my excel and each of these listboxes are filled with different data, also I use these listboxes to change some filters at a pivot table using a VB...

C#: ListBox SelectedIndex changes itself when method returns

c#,winforms,listbox
I have a problem with ListBox in c#(winforms). This ListBox contains the list of files(only pictures) in a specified directory like this: private ListBox FileList = new ListBox(); private List<string> Directories = new List<string> { @"some path", @"some other path", @"..." }; private List<string> Pictures; private int selectedDirectory = 0;...

TextBox.TextChange to update an onscreen ListBox in C#

c#,forms,search,textbox,listbox
Now this might not sound horribly cryptic, but I'm a little new to handling on-screen elements and Forms and such in C# so bear with me here. It's also going to be a bit of a long one, as I feel I should provide as much information as possible. I...

Having trouble populating listbox from xml elements

c#,xml,winforms,listbox
The XML is as followed: <?xml version="1.0" encoding="utf-8"?> <Folder_Settings> <Documents>Checked</Documents> <Pictures>Not Checked</Pictures> <Music>Checked</Music> <Videos>Not Checked</Videos> <Downloads>Checked</Downloads> <Contacts>Checked</Contacts> <Favorites>Not Checked</Favorites> <Other>Checked</Other>...

How to specify a file extension mask with MATLAB dir function

matlab,listbox
I'm working on GUI matlab I want display only sound waves in a listbox from a specific folder. When I click on a button the sound wav will be listed in a listbox. The code I'm using diplays all what is in the folder. function Display_Callback(hObject, eventdata, handles) % hObject...

C# listbox array trouble

c#,arrays,debugging,listbox,freeze
All. I am creating a program that takes a list of teams as a string array and compares it to a .txt file that contains a list of all the World Series winners and determines how many times a team has won the World Series based off which Team you...

How do I Random all the items in the listbox?

c#,xaml,random,listbox,windows-store-apps
I don't want to random number, I want to random all the items in the listbox in C# XAML Windows Store App?? Anyone have code for that or have any idea how to do that? I have this code of listbox <ListBox Name="Playlist" Background="White" DoubleTapped="Playlist_DoubleTapped" KeyUp="Playlist_KeyUp" Foreground="Black" SelectionMode="Single" SelectionChanged="Playlist_SelectionChanged" ScrollViewer.VerticalScrollMode="Enabled"...

WPF ListBox select next item after deletion with ICommand

wpf,xaml,mvvm,datagrid,listbox
This question evolves kind of the same issue like this question, but it concerns a different problem that I face because I use bindings. I have added a button to delete the currently selected item from a ListBox (and one for a DataGrid where the same problem arises). The code...

C# adding/subtracting/multiplying/dividing different items in listbox based on first character of item

c#,math,textbox,listbox
I have a program at the moment that adds items to a list box, the items consist of a character (+,-,*,/) followed by numbers. I have been attempting to get my program to recognize the first character of the item in the list box and doing the math appropriately all...

How to remove duplicates in ListBox?

delphi,listbox,duplicate-removal
I use this code to remove duplicates: procedure TForm1.RemoveDuplicates(StrList : TStringList); var NoDuplicate: TStringList; i: Integer; begin NoDuplicate := TStringList.Create; try NoDuplicate.Sorted := True; NoDuplicate.Duplicates := dupIgnore; /// for i := 0 to StrList.Count - 1 do NoDuplicate.Add(StrList[i]) ; /// NoDuplicate.Sorted:= False; StrList.Assign(NoDuplicate) ; finally NoDuplicate.Free; end; end; It works...

Detect when a ListBoxItem is in the SelectedUnfocused state

c#,wpf,listbox,focus,visualstates
Problem I want my Listbox to UnselectAll() whenever the user clicks anywhere outside of it. What I've done so far The following code works fine for all clicks inside the application: private void ListBox_LostFocus(object sender, RoutedEventArgs e) { ((ListBox)sender).UnselectAll(); } Clicking anything outside of the Listbox causes it to lose...

WPF Data Binding confusion

c#,wpf,xaml,listbox
I've just started taking up a course about WPF and I'm a bit confuse about some areas related to Data-Binding. I have no syntax issue, but most probably committed some newbie errors and I have couple of questions. I've done a simple screen with 2 textboxes and I when I...

ScrollIntoView doesn't work with Touch

c#,scroll,listbox,touch,pushpin
So I have a map with a number of PushPins on it and a list down the right hand side listing all the PushPins (using the same view models) When I click a pin on the map I want to scroll the item into view on the list. I currently...

Clickable listbox to open text document VB.NET

vb.net,listbox
this is my code Dim InputStr As String = CrystalClearTextBox1.Text For Each FileStr As String In IO.Directory.GetFiles("C:\Users\root\Desktop\databases", "*.txt") If IO.File.ReadAllText(FileStr).IndexOf(InputStr) >= 0 Then ListBox1.Items.Add(IO.Path.GetFileName(FileStr)) Else ListBox1.Items.Add("No Results found!") End If Next End Sub Also instead of just .txt, is it possible to add .csv, .sql? What I am trying to...

Select2 using Ajax (multi select) - when selecting second one first one disappars

jquery,ajax,model-view-controller,listbox
I am stuck on this problem - the ajax call retrieves the categories ok from the database, and when I select the search result the first time it also shows up in the search box. It is only when I select the search result the second time, first and second...

update listbox item when item is tapped

c#,wpf,xaml,windows-phone-8,listbox
I have a listbox wit listboxitems with an image and a textblock. The listbox has a custom class as datasource. What I want is when the listboxItem is tapped. The image inside the listboxitem changes. Here is what I have so far: My custom class: public class MemberUser { [JsonProperty("member_id",...

C# WPF ListBox Chat

c#,wpf,listbox,chat
I'm working on C# WPF Chat application. I want it to look like Skype chat, so last added item is touching the bottom of ListBox. Screenshot: <ListBox Name="ListBoxMain" Grid.Column="1" Grid.Row="1"> <ListBox.ItemTemplate> <DataTemplate> <WrapPanel> <TextBlock Text="{Binding User}" FontWeight="Bold" /> <TextBlock Text=": " FontWeight="Bold" /> <TextBlock Text="{Binding Text}" Width="225" TextWrapping="Wrap" HorizontalAlignment="Stretch" />...

WPF Extended ListBox doesn't find definition

wpf,xaml,listbox
have extended ListBox to give me a horizontal List Box, i.e, in XAML: <ListBox x:Class="Renishaw.Inspire.InTheatreCompanion.View.HorizontalListBox" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Style="{x:Null}"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel Name="ItemContainer" Orientation="Horizontal"/> </ItemsPanelTemplate> </ListBox.ItemsPanel> </ListBox> and in the code behind public...

C++ Windows API DlgDirList sometimes don't return the correct listing

c++,winapi,listbox,directory-listing,file-listing
I have 2 List Box, one always listing directories from a path and other listing the files from the selected directory. The first time i select a directory, the files are shown properly, but if i select another directory, it lists nothing. That's my current main.cpp, where all GUI stuff...

Customizing a Listbox - How to pass a Listbox Reference to a Converter from within an ItemTemplate?

c#,wpf,listbox
I have a list of objects with properties Name and Value which are shown in a listbox. The list is ordered by Name and i need to show the sum of the values of all preceeding objects in a third column of my Listbox. I created an ItemTemplate from where...

Listbox SelectedItem binding to UserControl

c#,wpf,xaml,binding,listbox
I want to bind a ListBox SelectedItem to This is my code for Listbox in my UserControl.xaml Style x:Key="listbox" TargetType="ListBox"> <!-- Region Setter Properties --> <Setter Property="SelectionMode" Value="Single" /> <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type program:UserControl}}, Path=Source}" /> `<ListBox Name="ListBox" Grid.Row="1" SelectedIndex="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type...

WPF ListBox with CheckBox data template - Binding Content property of Checkbox not working

c#,wpf,xaml,checkbox,listbox
I am following Kelly Elias' excellent article on making a WPF checkListBox. However, in my case, I have to create my objects in code using reflection. The ListBox item source is populating appropriately and the data template is styling the ListBox correctly, resulting in a list of CheckBoxes, but no...

How to populate a ListBox with DropDownList Text using ASP.NET C#?

c#,asp.net,drop-down-menu,listbox,datasource
I have an Access database with four different headers: BUSINESS AND FINANCE, COMPUTERS, TECHNOLOGY, EDUCATION. I have connected it to a ListBox using an asp:AccessDataSource, and it is showing up perfectly. I am now trying to set it that when i select an option in a DropDownList (either Business and...

Delphi. Firemonkey. TListbox. Is scrollbar visible?

delphi,listbox,firemonkey,delphi-xe5
I want resize my form height by ListBox items count - increase height while scrollbar visible. How to know, is scrollbar visible or nor in TListbox? So, there are a tons of information for VCL (based on Handle) but not for FMX. Lazy method: ListBox1.Items.Count * Round(ListBox1.ItemByIndex(0).Height) This method not...

Userform listbox rowsource not populating

excel,excel-vba,listbox,userform
I have a userform with an OK and Cancel button and a listbox. It is supposed to populate using this code: Private Sub UserForm_Initialize() Me.StartUpPosition = 0 Me.Top = Application.Top + (Application.Height / 2) - (Me.Height / 2) Me.Left = Application.Left + (Application.Width / 2) - (Me.Width / 2) With...

Button WrapPanel ListBox not wrapping in WPF

c#,wpf,button,listbox,wrap
I am trying to create a WrapPanel ListBox with a Button DataTemplate using this style: <Style x:Key="lbxStyle" TargetType="ListBox"> <Setter Property="Background" Value="{StaticResource primaryBrush}"/> <Setter Property="Foreground" Value="White"/> <Setter Property="VerticalAlignment" Value="Top"/> <Setter Property="VerticalContentAlignment" Value="Top"/> <Setter Property="ScrollViewer.CanContentScroll" Value="True"/> <Setter Property="ScrollViewer.VerticalScrollBarVisibility"...

WPF How to make listbox items editable?

c#,wpf,xaml,listbox
I need to add the "edit selected item" functionality to my listbox. Basically I need either of two: Ctrl+Click on list item and it magically becomes an editable textbox or something and when edited update the data in the database. Press the "Edit" Button under my ListBox, open the new...

Print all listbox items

c#,listbox
I am trying to print all of listbox items. The output should be like this: asd qweasd asdkjh but what happens is this: asd asdqweasd asdqweasdasdkjh Here is my code. a = bname.Items; var sb = new StringBuilder(); e.Graphics.DrawString("Book", fontm, Brushes.Black, 20, 170); foreach (var item in a) { sb.AppendFormat("{0}",...

How to get the value from listbox?

c#,listbox
I am writing a C# windows form application program. I have a code part like: listBox1.Items.Add(comboBox1.SelectedItem + "\t" + "\t" + textBox5.Text + "\t" + textBox4.Text + "\t" + textBox6.Text + "\n"); Here I want to take the value of textBox6.Text and I want to assign it to a double...

Reading seperate integers in a line

vb.net,visual-studio-2010,visual-studio,visual-studio-2012,listbox
I have a line of text and integers like this: Text 10 9 8 My code so far reads integers like this: 1 10 109 1098 My Code: Dim total As String For x = 0 To listbox1.Items.Count - 1 For Each ch As Char In listbox1.Items(x) If Char.IsDigit(ch) Then...

Can't add strings to listbox

c#,winforms,listbox
Hi i'm trying to collect output of this library into listbox. Here's part of code from the test project, with i've tried to modify: public partial class Form1 : Form { D.Net.Clipboard.ClipboardManager Manager; public Form1() { InitializeComponent(); Manager = new D.Net.Clipboard.ClipboardManager(this); Manager.Type = D.Net.Clipboard.ClipboardManager.CheckType.Text; Manager.OnNewTextFound += (sender, eventArg) => {...

Peculiar listbox.Requery visual bug

vba,ms-access,listbox,access-vba
I have a listbox which filters upon AfterUpdate event based on a value in combobox. All works fine, except sometimes it doesn't show all records properly. However, if I were to simply click on a line in the listbox, it correct itself. Moreover, the way it shows the data when...

tkinter Listbox loses its selection when clicking elsewhere on the form

python,tkinter,listbox
When a tkinter form includes a listbox and other widgets, clicking on the other widgets (especially if the mouse is dragged) causes the listbox to lose its selection -- meaning that the element(s) that was/were selected/highlighted in the lisbox become unselected. I've seen this problem discussed in one or two...

The selected item in a listbox is null how can i fix that?

c#,asp.net-mvc,asp.net-mvc-4,listbox
I am working on a listbox system that allows exercises in a regime to be deleted using a remove method in my controller. Currently when i select an item then click remove it returns an empty list of items and no changes are made to the db At the moment...

WPF ListBox SelectedItems determine Ctrl or Shift pressed for selection

wpf,listbox
I need to know, if the SelectedItems got filled when Ctrl or Shift was pressed or not. Is there an easy way (without creating a new controltemplate) to get this info? I prefer solutions without code behind. Best regards Yannik...

How to make if statement that checks if multple listBoxes are empty or not?

c#,winforms,if-statement,listbox
How do I make an if statement that asks if multiple listBoxes are empty or not? This is what I have so far...is it possible to combine it into one single if statement? if (listBoxEmails.Items.Count < 1) { //Perform action } if (listBoxWebsites.Items.Count < 1) { //Perform action } if...

how to set a listbox background color

c,winapi,listbox
I don't know how set a ListBox background color, not just one item. g_hChatEdit(listbox) Code: case WM_MEASUREITEM: if ((UINT)wParam == IDE_CHATEDIT) { LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam; lpmis->itemHeight = 22; HBRUSH hbr = CreateSolidBrush(bkgrgb); SetWindowLong(g_hChatEdit, GCL_HBRBACKGROUND, (LONG)hbr); //BeginPaint(g_hChatEdit, &ps); hdc=GetDC(g_hChatEdit); RECT rc; GetClientRect(g_hChatEdit, &rc); FillRect(hdc, &rc, hbr); InvalidateRect(g_hChatEdit, 0, true); UpdateWindow(g_hChatEdit);...

hittesting on Listitems in a Listbox

c#,wpf,listbox
I customized a Listbox to show a Pie-Chart (each Listitem is one slice of the Pie). To do this i used an Itemtemplate which (for now) only consists of a Shape. To make those shapes form a full circle, i calculated start/endangle for each piece and used a custom ItemsPanelTemplate...

Asp.net webforms ListBox Grouping

c#,asp.net,listbox,optgroup
I have a webform page that has a Listbox on it with a list of cameras on it. It is populated by a datatable that has a column for camera name, ip address, and group. DataClasses1DataContext dc = new DataClasses1DataContext(); public List<CameraTable> CameraListBox; public List<ListItem> SelectedListBox; protected void Page_Load(object sender,...

How to drag Multi items between 2 listbox in C#?

c#,drag-and-drop,listbox
I can drag one item from listbox1 and drop it to listbox2 but how can i do it when i select multi items from listbox1? private void FrmCh3_Load(object sender, EventArgs e) { listBox2.AllowDrop = true; } private void listBox1_MouseDown(object sender, MouseEventArgs e) { listBox1.DoDragDrop(listBox1.SelectedItem, DragDropEffects.Copy); } private void listBox2_DragEnter(object sender,...

How can I set the colour of a listbox item to match the colour of a picture box I have clicked

c#,listbox
I have a listbox with 100 items and several picture boxes each of different colours. When I click a picture box I want the background of the currently selected item in the listbox to change to the colour of the picturebox. I think I need some way of calling the...

ListBox ItemsPanel Style

c#,wpf,listbox
I'm trying to stylize my ListBox and I would like that my Items like this: 1 4 7 10 13 16 19 22 25 28 2 5 8 11 14 17 20 23 26 29 3 6 9 12 15 18 21 24 27 30 Only 3 items vertically and...

tkinter listbox display problems

python,list,tkinter,listbox
I've been trying to get a listbox to work, however, I've had no success at all. The box appears, and the data too... but all together. I have a list that looks something like this: lst=["item1","\n","item2","\n","item3","\n"] my listbox code looks somewhat like this: s="" for x in lst: s+=str(x) itemlist=Listbox(window)...

How to pass all value of ListBox Control to a function?

vb.net,listbox
I am writing a simple application to read the value a textbox and add to a listbox control . But i have to pass the listbox control to function . Any suggestion ? Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load test("E:\Satyajit.txt") End Sub Public Function...

WPF bind CustomControl's property in ListBox

c#,wpf,xaml,listbox
I have following ListBox in my WPF application: <ListBox x:Name="Domaci_soupiska" Margin="0" Background="#FFF1DE8A" AllowDrop="True" Drop="Soupiska_D_drop" Grid.Column="1"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <Label Content="{Binding Typ, Mode=TwoWay}" /> <local:HracControl Hrac="{Binding Hrac, Mode=TwoWay}"/> <TextBox Text="{Binding Cas, Mode=TwoWay}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> which...

show axes on click - matlab

matlab,user-interface,listbox,matlab-guide
I have a listbox button , lets say it contain 3 options : '1' '2' '3'. I also have 5 axes. When '2' is selected I plot something on this 5 axes. What I wanted to know is how to make 5 more axes that will be shown only in...

Automatically select renamed item in a listbox

c#,forms,listbox,selectedindex
I have a listbox which contains many items (each item in the listbox comes from a datasource). The items are ordered by name. I have a button in main form. When I choose an item in the listbox and click the button the item will appear in a new form....

Adding items to a ListBox in a parallel way

c#,wpf,listbox,task-parallel-library,backgroundworker
I'm writing a simple application (for testing purposes) that adds 10 M elements to a ListBox. I'm using a BackgroundWorker to do the work and a ProgressBar control to display the progress. Each element is a just a "Hello World!" string with and index that I'm adding during the process....

Problems with displaying an user selection from a Combobox in a Listbox

python,combobox,tkinter,listbox
I want the follow code snippet to take the user selection from the combobox and display it in a Listbox I have set up. When I run the code, and select from the combobox, the selection is displayed in the listbox as <tkinter.StringVar object at 0x1007ae748> instead of the actual...

Disable other listboxes unless the user have selected on the first listbox

jquery,asp.net,listbox
How am I going to disable my other listboxes unless the user have chose from my first listbox? <asp:DropDownList ID="ddlLead1" runat="server"> <asp:ListItem Text="-Please Select-" Selected="True" Value="-Please Select-"/> <asp:ListItem Text="Type 1" Value="Category 1" /> <asp:ListItem Text="Type 2" Value="Category 2" /> <asp:ListItem Text="Type 3" Value="Category 3" /> </asp:DropDownList> <asp:DropDownList ID="ddlLead2" runat="server"> <asp:ListItem...

Proper Formatting in a listbox

vb.net,listbox,formatting
I'm trying to format my listbox so that it looks neat when its in use. I want to add dollar signs to my numbers, and left align them. Any help would be appreciated. They currently look really sloppy. Dim salesTotal As Double customerListBox.Items.Add("Customer: " & " " & "Total Sale:...

Populating a ListBox from search criteria entered into a TextBox in Excel VBA

excel,vba,excel-vba,listbox,userform
I have posted this problem before, however, I think it was overly complicated and I didn’t explain it very well. This time I am just using a simple UserForm as an example. I want to populate a ListBox by entering search criteria in a Textbox. I have three columns: Column...

Images not appearing on WPF form when loading asynchronously

c#,wpf,multithreading,listbox,backgroundworker
I'm attempting to display (in a ListBox with a custom DataTemplate) a series of BitmapSource frames (thumbnails) extracted from a multi-page tiff image. When I process the tiff on the UI thread, and either directly add the images to a listbox's item collection or add them to a bound ObservableCollection,...

The best way to databind a ListBox Selected Item to DataGrid WPF

wpf,listbox
Hi New WPF programmer here. I can't seem to get this to work and I was hoping maybe you had some ideas. I'd like for when I select an Item in the User Defined table (ListBox), that it populates the data (ObservableCollection) into my datagrid. Then I'll use the Insert...

How can i get the correct information to display in my listbox?

c#,asp.net,asp.net-mvc,razor,listbox
I have two Listboxes where you can move exercises from an available list of exercises to a list of selected exercises for a specific user. My current problem is that my selected list (aka RegimeItems) shows the exercises for all of the users. I believe the problem lies in ChosenExercises(at...

C++: socket encoding (working with TeamSpeak)

c++,encoding,listbox
As I'm currently working on a program for a TeamSpeak server, I need to retrieve the names of the currently online users which I'm doing with sockets - that's working fine so far.In my UI I'm displaying all clients in a ListBox which is basically working. Nevertheless I'm having problems...

Why is selected value null in wpf listbox?

c#,wpf,xaml,listbox
I have connected to a database using entity framework and put the make and model of cars into a listbox in the format: Make - Model. When I select an item from the listbox I would like to get the ID of that object to use it in another query...

VB Listbox remove item

vb.net,visual-studio,listbox
In a listbox I want to remove an item but keep the others. I've tried this code but it doesn't work. ListBox1.Items.Remove(ListBox1.Items.IndexOf("TEST")) Googled around but couldn't find a working method. Any help appreciated....

How to resize a Win32 listbox to fit its content?

c++,winapi,listbox,autoresize
Is there any way to resize a Win32 listbox to fit its content (the minimum size that will show all its content, not needing a scrollbar), whenever its items change? Thank! Edit: I need resize both width and height of listbox....

Remove something added by a particular event - c#

c#,visual-studio-2010,checkbox,combobox,listbox
I have a piece of code that will add the selected item of a combobox to a listbox when a checkbox is checked. I would like to remove that selected item to be removed from the listbox when the checkbox is unchecked. My problem is I cant simply repeat the...

What is the alternative of Pivot Control in Windows 8.1?

c#,listbox,windows-8.1,win-universal-app
I am migrating my Windows Phone 8 app to Windows Universal Apps. I am currently working on Windows 8.1 project.In my Windows Phone 8 app , I used Pivot Control to show multiple pages and for each App bar was different and in that when I used to slide the...

ListBox that updates another part of View

c#,html,asp.net-mvc,razor,listbox
I want a ListBox, that when submitted, will send its selected values to a controller, and the response from that controller will be used to update a small piece of the view. The following code is able to update the part of the view, and get the selected values, but...

How to assign a selected value to a listbox item so it can be removed?

c#,asp.net,asp.net-mvc,listbox
I am currently working on a listbox that needs to have a function to remove/delete items from the listbox and ultimately the database. When an item(RegimeItem) is selected in the listbox, then the remove button is pressed the item is deleted from the database, that is what i want to...

Sync 2 list boxes to 1 scrollbar

vb.net,visual-studio-2012,scroll,listbox,listbox-control
I have 2 listboxes next to each other. One holds the order the other holds the total cost of the order. For obvious reasons i need both listboxes to scroll simultaneously. Here is what i have tried Private Sub lstOrders_Scroll() lstTotalsEachOrder.TopIndex = lstOrders.TopIndex End Sub Private Sub lstTotalsEachOrder_Scroll() lstOrders.TopIndex =...

How to get column width of a Win32 listbox?

winapi,listbox,width,multicolumn
I have a Win32 multicolumn listbox: HWND hListBox = CreateWindowEx(NULL, TEXT("LISTBOX"), NULL, LBS_MULTICOLUMN | WS_CHILD | WS_BORDER | WS_VISIBLE | WS_VSCROLL | LBS_NOTIFY, 0, 25, 600, 450, hWnd, NULL, NULL, NULL); I add items like this: SendMessage(hListBox, LB_ADDSTRING, NULL, (LPARAM)("New items")); After I add some items into hListBox, columns width...

Multiple listboxes created dynamically with event

c#,listbox
I'm creating dynamically multiple listboxes in c# using the for loop I want to add to eachone of them a SelectionChanged so that when a the selected item changed I display a content based on which listbox it is and the item. But it seems that the event is linked...

How to bind to a source inside a ListBox different from the ItemsSource already specified

c#,xaml,combobox,listbox
I have a ListBox inside a HubSection, whose Items are bound to a class "players" added to my DefaulViewModel via code behind. First I simply put a TextBox bound to the property "PlayerName" of my class "players". Now I would like to add a ComboBox with some items that are...

Text file not loading information into Listbox

vb.net,listbox,load
I'm trying to get the content from a text file into a Listbox, but I can't get it to work. It works fine however with a text box. Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click Dim filename As String Dim recipereader As StreamReader ofdLoad.ShowDialog() filename...

C# ListBox not showing added items when added from DispatcherTimer.Tick

c#,wpf,binding,timer,listbox
This looks like a weird behaviour to me and since I do not like to blame anyone else than myself I spent hours by trying to fix this - but I do not understand this at all: I just noticed that the problem occures in a method called by a...

How can I combine information in two different classes to show the result in a ListBox?

c#,wpf,listbox
My program contains two different classes. I want to combine the values of both, only to show the resulting information in a ListBox. The information is stored in a database, the classes in my code have been created by a LINQ to SQL DataClass. First class (ReactorParameters) This class contains...

C# WPF ListBox mouse click is late

c#,wpf,listbox,listitem,mouseclick-event
I am trying to have the text in a TextBlock update with the text from a ListBox item when I left-click that item. My C# code: private void listBox_MouseDown_rem(object sender, MouseButtonEventArgs e) { if (pathListB.SelectedItem != null) { rem_block.Text = pathListB.SelectedValue.ToString(); } } XAML: <ListBox Name="pathListB" PreviewMouseLeftButtonDown="listBox_MouseDown_rem" HorizontalAlignment="Left" Height="246" Margin="10,10,0,0"...

Access dropdown items in Google App Scripts UiApp

google-apps-script,listbox
I'm using the older depreciated UiApp class in javascript (because I have to) where I have a dropdown list I need to access the ListBox, and see all the values that it contains. Is there a way to do this? All the items must be present because there is method...