473,386 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How can i change listbox itemssource dinamically?

7
Hello dear C# coders. Picture this


.It's a simple practice GUI application that handles a library needs. I have a List of members, list for loans that each member does, I also have a "back up" loans list like global, and on MainWindow constructor it's like
Expand|Select|Wrap|Line Numbers
  1.  ... lstLoans.ItemsSource = loans; 
.
What I want is, the lstLoans.ItemsSource to be equal to member.Loans (each members list of loans done by this member), meaning, I want only this specific members Loans to appear each time, and not all loans done so far that got from loans (global list).
Is there any way to change dinamically I guess, the listBox items source, or just a way to show a specific members Loans, any other ideas beside list boxes.
Thanks in advance.
Attached Images
File Type: jpg i1542379_proj.jpg (32.2 KB, 2053 views)
May 18 '11 #1
2 4559
GaryTexmo
1,501 Expert 1GB
I don't know WPF that well so the best I can offer is a few educated guesses, but lets give it a try.

What are your loan list objects? I'd imagine they're lists of some kind, right?

You're asking if you can change the items dynamically... have you tried adding/removing items based on some GUI input? I'm not entirely sure what your overall goal is here... do you want to keep a master list of all the loans you had originally, but then modify that while preserving the original list? Or do you want something else?
May 18 '11 #2
Vagos
7
Loan is a class, containing information about a loan, done by a member. Here is some code from the Mainwindow :
Expand|Select|Wrap|Line Numbers
  1. public partial class MainWindow : Window
  2.     {
  3.         List<Member> members;
  4.         Member member;
  5.         ObservableCollection<Loan> loans;
  6.         //CollectionViewSource loans;
  7.  
  8.         public MainWindow()
  9.         {
  10.             InitializeComponent();
  11.             members = GetMembers();
  12.  
  13.             //member = GetMember(textBox1.Text); 
  14.             loans = new ObservableCollection<Loan>();
  15.             List<Title> titles = GetAllTitles();
  16.  
  17.  
  18.             //DataContext = member;
  19.             lstTitles.ItemsSource = titles;
  20.             lstLoans.ItemsSource = loans;
  21.         }
.User enter's the members code to the textbox then press the search button so he gets the secific members info. Pressing the newLoan button, down to the loans Listbox, the loan is added nornally, so you can see 'this' member loans. But, when you enter a new member code to the textbox and press Search button, you can still see the previous members loans, and also 'this' members loans done so far.
Any way to show only 'this' member loans at any time?
May 18 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: TF | last post by:
Hi, Is there any way to change the text color of SOME of the ListBox(Windows Forms Control) items in VB.NET? TF
1
by: craigkenisston | last post by:
I have a project, in which in my default.aspx page, I dinamically load a user control in codebehind, in the pageload, that manages the website : Control objPageSkin = null; HtmlForm objForm =...
2
by: softengg | last post by:
Hi, I have so many items in a listbox (strings such as Apple, Orange, Grapes..etc) and I want to change these to Uppercase and Lower case. Please anybody tell how this is possible in C#.Net ...
2
by: pplers | last post by:
I'd like to know if there's a way to make the color of a cell/button change using onMouseOver. Is there some sort of "built-in" function to do this ? Thank you.... p.s: If possible, the...
5
by: datasec23 | last post by:
Hi...I am trying to get my listbox data to change based on a field on a form. Each time I click on the next record indicator at the bottom of the form, I would like the Listbox to change...
5
by: Academia | last post by:
(If you've seen this in the drawing NG, sorry. I inadvertently sent it there.) I have a listbox populated with Objects. The Class has a String field that ToString returns. I assume that...
1
by: Shimon Sim | last post by:
I can't figure out how to bind ComboBox inside of ListView or ListBox. How do I set ComboBox.ItemsSource property? I don't see the way to do it in code and not in XAML. I have Collection that is...
2
by: BbEsy | last post by:
Hello all I new in silverlight And i found one strange thing.. when i tried to bind List of object to datagrid all works fine. Values shows fine... But, when i try to use linq to select only one...
2
by: Vagos | last post by:
Hello, I am using list boxs, my NewLoan button works just fine, adds the loans to the specific lstLoans area, but this code won't delete the selected item, any suggestions? Here is the code : ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.