w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Listbox width changes regardless of size of list items
I managed to fix this issue by writing a MultiValueConverter which takes in an image filepath and a pixel width (bound in xaml using a MultiBinding) and returns the correct size bitmap to display in the thumbnail Image control. The result is that the correct size image is used (and cached) so the ListBox width is constant. This is the code for the converter: public class PathToThumbnailConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { var path = values[0] as string; var decodeWidth = (int)values[1]; if (!string.IsNullOrEmpty(path)) { var info = new FileInfo(path); if (info.Exists && info.Length > 0) { v

Categories : Wpf

remove delete item from listbox list of items
Hey Try to Get Selected item index from your collection then remove item form collection by index then again bind your list box to collection.. I have made sample code please refer. public partial class Form1 : Form { List<String> lstProduct = new List<String>(); public Form1() { InitializeComponent(); } public List<String> BindList() { lstProduct.Add("Name"); lstProduct.Add("Name1"); lstProduct.Add("Name2"); lstProduct.Add("Nam3"); lstProduct.Add("Name4"); return lstProduct; } private void Form1_Load(object sender, EventArgs e) { listBox1.DataSource = BindList(); } private void button1_Click(object sender, EventArgs e) { // The Remove button was

Categories : Dotnet

Update automatic ListBox items when alter List
Instead of using a List<T>, use an ObservableCollection<T>. It is a list that supports change notifications for WPF: // if this isn't readonly, you need to implement INotifyPropertyChanged, and raise // PropertyChanged when you set the property to a new instance private readonly ObservableCollection<Control> items = new ObservableCollection<Control>(); public IList<Control> Items { get { return items; } }

Categories : C#

Knockout -how to transfer multiselect listbox items(any orde selected items) to another listbox using Knockout?
Just use two observableArrays for available options of both selects. From one .remove(item) and .push(item) to the other. Knockout will track changes. Try an event or click binding. Or put this function in computed observable watching selected items. You didn't made a sample jsfiddle to help you some more with example.

Categories : Knockout Js

get multiple items chosen in a listbox and populate new list with the values, using Tkinter
I figured it out, instead of for i in lst_select: lbox.get(i) UsrFCList.append(i) It was for i in lst_select: UsrFCList.append(lbox.get(i))

Categories : Python

ListBox displays "System.Windows.Forms.ListBox.Items.Count..."
To write the items, change the line that does the write to: rollLog.WriteLine(lstBoxOut.items[count]); To read it back in: private void btnReadFile(object sender, EventArgs e) { lstBoxOut.Items.Clear(); foreach (string line in File.ReadLines("Roll Results.txt")) { lstBoxOut.Items.Add(line); } } The reason you're getting that output "System.Windows.Forms.ListBox...." is because the statement rollLog.WriteLine(lstBoxOut) is equivalent to rollLog.WriteLine(lstBoxOut.ToString()). The ToString() method returns A string that states the control type, the count of items in the ListBox control, and the Text property of the first item in the ListBox, if the count is not 0.

Categories : C#

Why I always get the first selected value from a ListBox when I call ListBox.SelectedValue and select items in ASC order inC#?
Try using SelectedItem instead: private void lstEquipos_SelectedIndexChanged(object sender, EventArgs e) { // Get the currently selected item in the list box string currentItem = lstEquipos.SelectedItem.ToString(); // Find the index of the currently selected item in the list box int index = lstEquipos.FindString(cucurrentItemItem); textBox1.Text = index.ToString(); }

Categories : C#

Hide items in a ListBox when ListBox is disabled
Just add another ListBox to the form and when you disable the first listbox with the elements inside of it, hide it, and then display the other to the user which will essentially be an empty greyed out listbox. Then when you enable the box back, hide the empty one and show the real one. Hope this helps.

Categories : C#

Are there anyway to make ListBox items to word wrap if string width is higher than ListBox width?
Helpful link Check out this answer. It overrides the template of the listbox with a textblock which wraps the text. Hope it's useful. To solve your problem I think you shold add : ScrollViewer.HorizontalScrollBarVisibility="Disabled" . Found it here

Categories : C#

How do I click a button that will remove an item from a ListBox and the List that holds the information for the ListBox in C#?
Your add method calls Add() on a base class. Do you have a remove on your base class? If so, use that. Otherwise change your ShoppingBasket class to be: The Orders list stores your OrderItems. Add and Remove from this list. public class ShoppingBasket { public List<OrderItem> Orders { get; set; } public ShoppingBasket() { Orders = new List<OrderItem>(); } public void Add(OrderItem orderItem) { Orders.Add(orderItem); } public void Remove(OrderItem orderItem) { Orders.Remove(orderItem); } } Usage: var basket = new ShoppingBasket(); basket.Add( new OrderItem { OrderItemId = 1, ... } ); // Remove an OrderItem basket.Remove( new OrderItem { OrderItemId = 1 } );

Categories : C#

Add items from 2 listBox to one listBox
For first part: listbox3.items.add(listbox1.SelectedItem.ToString() + listbox2.SelectedItem.ToString()); For second part: WebRequest request = WebRequest.Create(listBox1.SelectedItem.ToString() + listBox2.SelectedItem.ToString()); Final phase: If exception occurs and different url is expected then do select different url entries from both listbox1 and listbox2 and click the button to check. Also keep correct entries in both the listboxes to avoid exception.

Categories : C#

WPF Listbox Items
You may want to explore an MVVM approach. In one of your view model classes, you can have an ObservableCollection<string>: public ObservableCollection<string> StuffForListBox { get; set; } Populate that ObservableCollection with what you want to get displayed in the ListBox. In the code-behind of the UserControl or Window in which you have the ListBox, set the DataContext to an instance of the class containing StuffForListBox seen above. this.DataContext = new MyClass(); Alternatively you could also create a datatemplate for the usercontrol / window which will automagically wire up the datacontext with your view model. Since you only mentioned that you want to display the files in a directory (not including sub-directories), you just need to bind the ItemsSource to St

Categories : Wpf

How to add items to the other ListBox in VB?
Your problem is, probably, in trying to access the second form directly. To access it from the first form declare a new second form, 'Dim Sec as New Second'. Now you can access all the controls in the second form, from the first. Then use 'Sec.Show()' to show the form. Also what is the datasource of the listbox in the second form?

Categories : Vb.Net

Adding Sharepoint 2010 List Items to a List with external Items
One option is to create an SQL server trigger. This trigger would fire whenever a new sales order is created in your source database. You could make it a CLR trigger, and in the function make use of the SharePoint client interface. After you provided a clearer description of the problem: I believe that you're looking for something like the list event handler. This will run on the events you care about, and you can pull from the database at the appropriate time. Essentially, you need to make a Visual Studio SharePoint project (from my past experience this method requires you to use VS right on the SharePoint server, or else you have to copy a lot of DLLs manually from the server); and make an event receiver.

Categories : SQL

jQuery replacing list items with different list items with specific classes
You don't have to use .load there, If, classes are already there, you don't have to do anything - Simply remove this Line $(this).load("li a.add-this-list-on-click-instead > *").fadeIn("slow"); and if .add-this-list-on-click-instead are hidden initially - then just make it visible with this - $("#dynamic").click(function() { $this = $(this); var refreshId = setInterval(function() { $('.remove-this-list-on-click').fadeOut("slow", function () { $this.find("a.add-this-list-on-click-instead").fadeIn("slow"); }); }); });

Categories : Jquery

Select items from Listbox, one by one
Do what you want to do but i don't understand why you need to select an item form listbox. but you can get the items by listBox1.Items[i] and then can calculate the size. Use below code to do that what you wanted. for (int i = 0; i < listBox1.Items.Count; i++) { listBox1.SelectedItem = listBox1.Items[i]; //Calculate the total size of items present in listbox here }

Categories : C#

Add multiple items in a listbox row
See the example from the MSDN ItemsControl.ItemTemplate <ListBox Width="400" Margin="10" ItemsSource="{Binding Source={StaticResource myTodoList}}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Path=TaskName}" /> <TextBlock Text="{Binding Path=Description}"/> <TextBlock Text="{Binding Path=Priority}"/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> It should be pretty straight forward to match with your example.

Categories : C#

More highlighted items in a listbox
To avoid this you'll have to use a wrapper around your strings; your Picture objects seems a good start. Here is a sample that illustrates the two approaches: XAML: <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" xmlns:local="clr-namespace:WpfApplication1"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Gr

Categories : C#

Not able to return items in listbox
Since you're adding the options with JS, your server doesn't know this. When you post the values back, they didn't exist at run-time so it grabs the original count (1). You'll have to use another method to get the newly added values, example: add them to a hidden field with runat='server' and grab the values from that.

Categories : Javascript

In ListBox cannot add Items after ItemSource is set to null
The two-way binding on ListBox2.ItemsSource sets ListBox1.ItemsSource to null when ListBox2.ItemsSource is set to null. Subsequently, the two-way binding on ListBox1.ItemsSource also sets Coll to null. Don't make the ItemsSource bindings two-way. It is not necessary, and collection changes will still be notified. <ListBox x:Name="ListBox1" ItemsSource="{Binding Coll}" ... > ... </ListBox> <ListBox x:Name="ListBox2" ItemsSource="{Binding Path=ItemsSource, ElementName=ListBox1}" ... > ... </ListBox> It's not really clear what you are going to achieve, but it may be better to also bind ListBox2.ItemsSource directly to the Coll property.

Categories : Wpf

How to copy Items from Datagrid to Listbox
If you want the instance of the object to enter the listbox, you cannot control the tostring method like you do: lstSelected.Items.Add(iFacilitiesDataGrid.SelectedItem.ToString()); Instead, cast your selecteditem to the type: lstSelected.Items.Add((HM.IFacility)iFacilitiesDataGrid.SelectedItem); If you don't want the object to enter the listbox, but just some properties from that object, then you have to override the tostring in your object. If you don't do that, the tostring will give you the type of the object, like you said --> "HM.IFacility" to override the tostring, put this in your object class: public override string ToString() { return property1 + " " + property2 } Where property1 and property2 are properties on your object class (like name, age, or id)

Categories : Wpf

Highlight multiple items in listbox
Guess you need something like this: <ControlTemplate TargetType="ListBoxItem"> <TextBlock Text="{Binding LastOperation}"> <TextBlock.Style> <Style TargetType="TextBlock"> <Style.Triggers> <DataTrigger> <DataTrigger.Binding> <MultiBinding> <Binding Path="MouseOverIndex"/> <Binding Path="CurrentIndex"/> </MultiBinding> </DataTrigger.Binding> <Setter Property="Foreground" Value="Gold"/> </DataTrigger> </Style.Triggers>

Categories : C#

ListBox items changes based on condition
use a value converter. see some samples here Create a converter class public class PurchaseStatusConverter : IValueConverter { private const double comparePrice = 2000; public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { double price; if (double.TryParse(value.ToString(), out price)) { return price > comparePrice ? "Purchased" : "Not Purchased"; } return "-"; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } In your app.xaml, define the converter, take care of namespaces, re-sharper should handle this for you if you have

Categories : Json

How can I bind to all items in a wpf ListBox and specify a converter?
I think you just need to add the element name to point it back to the listbox, (assuming that's what you are trying to do) FontStyle="{Binding ElementName=listViewTakeOffConfigurations, Path=SelectedItem, Converter={StaticResource estimatingTakeOffConfigurationToFontStyleConverter}, Mode=OneWay}"

Categories : Wpf

How to export listbox items into XML file
Try the above var xml = new XElement("Items", from s in strings let parts = s.Split('=') select new XElement("Item", new XAttribute("Key", parts[0]), parts[1] ) );

Categories : C#

Sending all items to textbox from listbox in vb?
To do something like that, you need to loop through all of the items in the list and combine them all into a single string. Then you can display the formatted string in the text box. The best way to continuously append to a string is to use the StringBuilder class, like this: Dim builder As New StringBuilder() For Each i As Object In ListBox1.Items builder.AppendLine(i.ToString()) Next TextBox1.Text = builder.ToString()

Categories : Vb.Net

C# - remove part of listbox items
Understanding from your comment you only need the filename of the files, without the path or the extension. For that you can use Path.GetFileNameWithoutExtension string[] songspaths = System.IO.Directory.GetFiles(librarypath + "/" + albumpath + "/" + songpath); // Get all the files from the specified directory List<string> listsongs = new List<string>(); foreach (var f in songspaths) { lstSong.Items.Add(Path.GetFileNameWithoutExtension(f)); // Store the filename without path or extension in the list } And to explain the code your friend has wrote: string songs = f.Split('\').Last(); The string.Split method diviedes the string into an array of substrings delimited by the given character. In this case it's an (escaped) backslash. The .Last() returns the last element

Categories : C#

Exception while Refresh-ing Items of ListBox
It would be better to maintain your own list separate from the Dictionary and copy values over when the Dictionary changes. I'd advise using an ObservableCollection, so you don't have to do a refresh call. I swear I still have my code for an ObservableDictionary somewhere.

Categories : C#

c# and wpf crisis with blank listbox items
FoodInformation class does not contains properties: Image and Name (you are trying binding to these properties in DataTemplate). From code-behind we can create definition of FoodInformation class with properties Dinner and DinnerImage: class FoodInformation { public string Dinner { get; set; } public ImageSource DinnerImage { get; set; } } So you should binding to properties Dinner and DinnerImage, not to Image and Name. If you change in DataTemplate appropriate properties names everything will be ok. <DataTemplate x:Key="templateListBoxItem"> <Grid Margin="5"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"></ColumnDefinition> <ColumnDefinition Width="*"></ColumnDefinition> </Gri

Categories : C#

How to synchronize listbox items in two forms?
The easiest (and best) way is to bind both the ListBoxes' (even 3, 4 or more) DataSource to the same one. We have to use BindingList<> instead of List to benefit the capability of notifying changes in collection. BindingList<object> listData = new BindingList<object>(); listBox1.DataSource = listData; public void ShowForm2(){ ListBox list = new ListBox(); list.DataSource = listData; Form f = new Form() { BindingContext = this.BindingContext };//Set BindingContext the same to synchronize tracking item in both listBoxes. list.Parent = f; f.Show(); } //This is used to add new item to the source public void AddItem(object item){ listData.Add(item); } //This is used to remove an item from the source public void RemoveItem(object item){ listData.Remove(item);

Categories : C#

how to add user controls as listbox items
You can set ItemTemplate for the listbox with your usercontrol in it. <ListBox> <ListBox.ItemTemplate> <DataTemplate> <local:UserControl1/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> Thanks

Categories : C#

Listbox items dont want to stretch
Note, you don't need to set the Horrizontal alignment setting to stretch unless it's in a container that overrides it. By default most XAML controls are set to take up the most space. Also check that your margins are not shrinking your containers below where you want them. (note you can use negative margins to stretch as well)

Categories : Dotnet

Accessing ItemsPresenter items in a ListBox
If container is not created (i.e., it is out of viewport bounds), you have to get the ScrollViewer which is the ListBox template child and then call the ScrollToHorisontalOffset method to create containers for items. After that you should also call the UpdateLayout to force container generation - here you can acces newly created container. Note that in has no correct value for RenderSize, but you can measure element and get its DesiredSize. Note that ContainerFromItem can return null if your listbox is collapsed or container generation is not started (or not finished) - check the ItemContainerGenerator.Status property.

Categories : C#

WPF XAML WrapPanel ListBox items in a row
The problem is that your WrapPanel only has a single child: The ListBox. This means that the layouting is done by the ItemsPanel template of the ListBox. Try this instead: <Expander Header="{Binding GroupName}" Style="{DynamicResource FeatureExpander2}"> <ListBox x:Name="ListOfTiles" ItemsSource="{Binding VideoSamples}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Width="120" Margin="10" HorizontalAlignment="Left"> <Image /> <TextBlock /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel /> </ItemsPanelTemplate&

Categories : Wpf

Items doesn't appear in ListBox in C#, but in XAML yes
I think it's because the ListBox1.Items collection does not implement the INotifyPropertyChanged/INotifyCollectionChanged. You could create an observable collection an assign it to the ItemSource. ObservableCollection<MyData> items = new ObservableCollection() items.Add(new MyData()); ListBox1.ItemSource = items; The reason you don't see it added, is that the listbox is already created/filled and the collection of Items does not notify the listbox when you call the .Add method on the Items property.

Categories : C#

Select items from a List where the children contain the items from another List using LINQ
If you want to return all the products which has all the provided categories in its Categories which means it selects product where it has category1 AND category2. Then you need to use the All with the combination of Contains: public List<Product> FilterProducts(List<Category> categories) { return products.Where(p => categories.All(c => p.Categories.Contains(c)) .ToList(); } If you want to return all the product where it has it least one cetegory from the provided categories which means it selects product where it has category1 OR category2. Then you need to use Any public List<Product> FilterProducts(List<Category> categories) { return products.Where(p => categories.Any(c => p.Categories.Contains(c)

Categories : C#

inserting items of listbox into sql server database
Sure, you could do something like this: using (SqlConnection c = new SqlConnection("your connection string")) { c.Open(); using (SqlCommand cmd = new SqlCommand("INSERT INTO table (field1, field2) VALUES (@field1, @field2)") { foreach (ListItem item in listbox2.Items) { cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@field1", item.Value); cmd.Parameters.AddWithValue("@field2", item.Text); cmd.ExecuteNonQuery(); } } } Now clearly the INSERT statement I provided would be different, and the parameters you add would be different, and maybe you don't need the Value and the Text, but you get the idea.

Categories : C#

Calculating the sum of items in a ListBox- Visual Basic
Your while loop conditions are incorrect since you are comparing the ListBox.Items.Count with the total sum. I would use Linq instead because it's much more readable: Dim totalMiles As Int32 = milesListBox.Items.Cast(Of Int32)().Sum() Dim totalGallons As Int32 = gallonsListBox.Items.Cast(Of Int32)().Sum()

Categories : Vb.Net

Adding concatenated strings as listbox items
Just build your string before you add it to the ListBox. string text = textBox1.Text + "hrs, " + textBox2.Text + "min, " + textBox3.Text + "sec."; if (checkBox1.Checked) text += " Novelty: " + textBox4.Text; listBox1.Items.Add(text);

Categories : C#

ASP.Net ListBox items to get in code behind which are added using jQuery
Hidden fields will be the silver bullets here. step1. add a asp hiddenfield to your page lets say hf1 is its id. step2. add a clientclick event to your save button step3.in the client clickevent get all personal skill and make them into a single string using comma or '|' step4. set the hf1 value to the string generated by step3 and then post it. step 5.On the server side get the value of the hf1 which will be the same string generated in 3rd step. step6. deserialize it and //do any thing you want. hope this help

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.