listbox

Add students name,surname and age from list to ListBox

限于喜欢 提交于 2019-12-20 06:28:13
问题 I have 3 textboxes where I can enter Name , Surname and Age . After i press button1, it makes a new student with these attributes. How can I add student with all 3 attributes to ListBox ? Look like this: /#/ -- Name -- Surname -- Age 1 -- John -- Smith -- 21 2 -- Tony -- Hawk -- 22 My code at the moment: public class Students { public string Name; public string Surname; public int Age; } public partial class Form1 : Form { List<Students> group = new List<Students>(); public Form1() {

How can I bind against the Index of a ListBoxItem

自闭症网瘾萝莉.ら 提交于 2019-12-20 06:27:34
问题 I'd like to bind the z index of list box items to their index. Ideally, we would have <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="Panel.ZIndex" Value="{Binding RelativeSource={RelativeSource Self}, Path=-Index}" /> <!-- ... --> However, the list box item does not have an index property. I can think of a number of crazy solutions but nothing simple and elegant. Any taker? 回答1: There is no Index property, but anyway "-Index" wouldn't be a valid path... you would still need a

Automatically filter/order ListBox items (Windows Phone)

情到浓时终转凉″ 提交于 2019-12-20 06:27:22
问题 I want to ensure, that the items added in my list box are ordered in ascending order according to the serial number of each item (e.g 1 item, 2 item, 4 item, 3 item should be automatically order according to its number 1.2.3.......10). Here is the C# source: namespace XeroQuiz { public partial class MainPage : PhoneApplicationPage { IsolatedStorageFile Settings1 = IsolatedStorageFile.GetUserStoreForApplication(); MyDataList listobj = new MyDataList(); public MainPage() { InitializeComponent()

Get ValueMember of Selected item in ListBox

。_饼干妹妹 提交于 2019-12-20 06:25:39
问题 I've seen a couple of posts asking a similar question but I have not been able to duplicate the answers in my code successfully. The following code adds items and their value member to a list box. Public Shared Sub ListFiles(hTab As Hashtable) Debug.Print("create file and key" & Now) Dim Enumerator As IDictionaryEnumerator Enumerator = hTab.GetEnumerator() Dim MyKeys As ICollection Dim Key As Object MyKeys = hTab.Keys() If (hTab.Count > 0) Then For Each Key In MyKeys Dim sfileName As String =

Bind textbox list inside listbox in wpf

你说的曾经没有我的故事 提交于 2019-12-20 05:11:46
问题 I have to make listbox with textbox in it... and it has to be dynamic. I have observable collection in code behind and I want to bind that for listbox. I want dynamic listbox and this list should have editable textbox in it. So, basically I want to bind multiplr textbox from listbox. Any help would be appreciated <ListBox HorizontalAlignment="Left" Name="ListTwo" Height="100" Margin="286.769,165.499,0,0" VerticalAlignment="Top" Width="100" ItemsSource="{Binding Source=obs}"> <ListBox

Updating the listbox after adding a new item

二次信任 提交于 2019-12-20 05:11:15
问题 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

How do you remove hyperlinks from a Microsoft Word document?

情到浓时终转凉″ 提交于 2019-12-20 04:55:45
问题 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

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

╄→尐↘猪︶ㄣ 提交于 2019-12-20 04:42:09
问题 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=

How to retrieve selected values for selected items in a ListBox?

这一生的挚爱 提交于 2019-12-20 04:28:08
问题 I'm populating a ListBox in a WinForms application, this way: listBoxUsers.DataSource = ctx.Users.ToList(); listBoxUsers.DisplayMember = "Name"; listBoxUsers.ValueMember = "Id"; how to retrieve the selected Ids when I'm setting the SelectionMode to MultiSimple I want to do a foreach loop on them, like this: foreach(var itemId in listBoxUsers.SelectedValues)//unfortunately not exist { int id = int.Parse(itemId); // . . . } 回答1: Since you know the type of items, you can use such code: var

Items collection must be empty before using ItemsSource

[亡魂溺海] 提交于 2019-12-20 03:55:23
问题 If I put a DataTrigger in a simple Listbox I get this runtime exception: Items collection must be empty before using ItemsSource My listbox without datatrigger (no exception): <ListBox ItemsSource="{Binding EdgedBoards}" SelectedItem="{Binding SelEdgedBoard, Mode=TwoWay}" DisplayMemberPath="Name"> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource {x:Type ListBoxItem}}"> <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay,