listbox

Updating the listbox after adding a new item

只愿长相守 提交于 2019-12-02 05:42:10
I am using WPF and C# I have a button that opens a window, which also includes a button that adds an User object item to a listbox and I want the listbox index to be updated after insertion. I understood that the solution is about using observable class of INotifyCollectionChanged but actually I dont know how and where to use them. Can you help me on determining what and where to implement, register, fire etc. Edit: I succeeded this by Quartermeister's help where my User object is collected in a list, but now I want to do the same thing where my object is collected in a dictionary The easiest

Reversed Listbox without sorting

我只是一个虾纸丫 提交于 2019-12-02 05:40:23
I spent last two weeks trying to figure out a method to display the items of a listbox in reversed order without using any sort property and without putting any presentation logic in my entities, I just want that the last inserted item is displayed at the top of the listbox. The only pure XAML solution I've found is this WPF reverse ListView but it isn't so elegant. I've also tried to override the GetEnumerator() of my BindableCollection (I use Caliburn Micro as MVVM framework) to return an enumerator that iterate over my collection's items in the reverse order but id did not work. How can I

How do you remove hyperlinks from a Microsoft Word document?

隐身守侯 提交于 2019-12-02 05:29:36
I'm writing a VB Macro to do some processing of documents for my work. The lines of text are searched and the bracketed text is put in a list(box). The problem comes when I want to remove all hyperlinks in the document and then generate new ones (not necessarily in the location of the original hyperlinks) So the problem is How do I remove the existing hyperlinks? My current issue is that every time a link gets added, the hyperlinks count goes up one, but when you delete it, the count does NOT reduce. (as a result I now have a document with 32 links - all empty except for 3 I put in myself -

Horizontal ListBox Items Stretching

我们两清 提交于 2019-12-02 05:27:40
I have a problem with my ListBox in WPF. First of all, I have a horizontal ListBox with custom ItemTemplate. Now, I want to stretch the items, so that the items fits over the complete width of the ListBox. I tried things like setting the HorizontalContentAlignment to Stretch , but this still not working. Here is my ItemTemplate : <DataTemplate x:Key="ListViewStepTemplate"> <Grid VerticalAlignment="Stretch"> <TextBlock Text="{Binding Path=Title}" FontSize="15" HorizontalAlignment="Center" VerticalAlignment="Center" /> <Image Height="16" Width="16" HorizontalAlignment="Right" VerticalAlignment=

How to get particular property from item selected in ListBox

会有一股神秘感。 提交于 2019-12-02 04:59:37
I have the following: <ListBox SelectedItem="{Binding SelectedItem}" ItemsSource="{Binding items}" DisplayMemberPath="s"/> <TextBlock Text="{Binding SelectedItem.s}"/> This is definition of SelectedItem public MemEntity SelectedItem {get; set;} MemEntity is a class containing public String s {get; get;}. Basically, I want s of the selected item to be shown in the TextBlock (same property as shown in ListBox ). This doesn't work, so what am I doing wrong? Try this, <TextBlock ... Text="{Binding ElementName=items, Path=SelectedItem.s}" /> then add a name to your ListBox as, <ListBox x:Name=

I need Horizontal view of list boxes

£可爱£侵袭症+ 提交于 2019-12-02 04:49:26
I am working on list boxes in WPF. I want to show the list boxes in horizontal direction. My code is <Grid> <ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto"> <ItemsControl x:Name="list" > <ItemsControl.ItemTemplate> <HierarchicalDataTemplate> <Border Padding="5,0,0,2"> <WrapPanel Orientation="Horizontal"> <ListBox Name="mylistBox" Width="200" Height="200"> <Label Content="{Binding name}"/> <Label Content="{Binding phone}"/> <Label Content="{Binding email}"/> <TextBox Name="NameTxt" Width="20" Height="20" Text="{Binding Path=Contact1.name}"></TextBox> </ListBox> </WrapPanel> <

Adding multiple listbox items to database

爱⌒轻易说出口 提交于 2019-12-02 04:46:18
问题 Is there any easy way to save the items in listbox to the database. I am using access database for windows form where user selects items from the combobox and adds it to the list box. Now i want to add all the items in the listbox to the database separated with comma. How can i perform this? Here is the code for the class using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System

(c# + windows forms) Adding items to listBox in different class

 ̄綄美尐妖づ 提交于 2019-12-02 04:38:31
问题 I have two classes(forms), and I would like an item from class2 to be added to listBox in class1 when I click "Accept" button. I tried with the following code, but nothing changes in the listBox: private void button1_Click(object sender, EventArgs e) { CarRental i = new CarRental(); string id = idRental.Text.ToString(); i.listBox1.Items.Add(id); i.listBox1.Update(); this.Close(); } Where did I make the mistake? 回答1: Declare RentalId property on Form2 . And at CarRental form (your first form)

Have a databound WPF Listbox generate subclassed ListboxItems

对着背影说爱祢 提交于 2019-12-02 04:35:40
问题 I would like to have my WPF Listbox, which is databound, generate subclassed ListboxItems instead of the regular ListboxItems. In this case, a DataTemplate is not sufficient because I need some custom properties for the subclassed ListBoxItems. Is there a way to have the ListBox generated mySubClassedListBoxItem items for the bound data? Thanks, Bart 回答1: You need to create your own subclass of ListBox so you can override the method which creates the container, e.g. public class MyListBox :

How to prevent page being postbacked when i transfer item from one listbox to other

孤人 提交于 2019-12-02 04:16:50
I have two listboxes in my application on button click i am pushing the item from one list box to other , the code works fine but it causes postback , while i move the item from one list box to other whole page is being loaded again , how i can prevent this . This will be the code on my aspx page <div class="bx1"> <telerik:RadListBox ID="RadListBox1" runat="server" DataTextField="Name" DataValueField="Id" Width="250px"> </telerik:RadListBox> </div> <div style="height:7px"></div> <div class="bx5"> <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="images/dwnArrow.png" OnClick=