Click here to Skip to main content
15,892,965 members
Home / Discussions / C#
   

C#

 
GeneralRe: Create Textfile Pin
5fingers5-Aug-09 3:07
5fingers5-Aug-09 3:07 
AnswerRe: Create Textfile Pin
musefan5-Aug-09 2:32
musefan5-Aug-09 2:32 
GeneralRe: Create Textfile Pin
5fingers5-Aug-09 3:11
5fingers5-Aug-09 3:11 
GeneralRe: Create Textfile Pin
stancrm5-Aug-09 3:18
stancrm5-Aug-09 3:18 
GeneralRe: Create Textfile Pin
5fingers5-Aug-09 3:46
5fingers5-Aug-09 3:46 
GeneralRe: Create Textfile Pin
stancrm5-Aug-09 19:12
stancrm5-Aug-09 19:12 
GeneralRe: Create Textfile Pin
musefan5-Aug-09 3:21
musefan5-Aug-09 3:21 
QuestionListBox won't bind Pin
Mustafa Ismail Mustafa5-Aug-09 2:05
Mustafa Ismail Mustafa5-Aug-09 2:05 
Disclaimer: This separate yet related to a question I posted in the LINQ forum, but since its regarding a different issue (ListBox) it can't be considered cross posting.

I'm sure this is a simple issue, but I'm completely stumped.

Essentially, what I'm trying to do is have people move items between ListBoxes which are bound to Lists. One ListBox contains the items selected by the from the full list and the other contains the rest of the items from the full list, where originally, the second list box contained the full list (on the assumption that the user has not made any selections)

here's the code:

//Lists as properties
List<RCH.EL.EMR.Allergies> AllAllergies
{ get; set; }

List<RCH.EL.EMR.Allergies> RemainingAllergies
{ get; set; }

List<RCH.EL.EMR.Allergies> PatientAllergies
{ get; set; }

//Method that seperates the items in the lists
private void ResolveAllergies()
{
    RemainingAllergies = AllAllergies.Except(PatientAllergies).ToList();
}

//Method that binds
protected override void BindListBoxes()
{
    lstAllergies.DataSource = RemainingAllergies;
    lstAllergies.DisplayMember = "AllergyAr";
    lstAllergies.ValueMember = "ID";

    lstPatientAllergies.DataSource = PatientAllergies;
    lstPatientAllergies.DisplayMember = "AllergyAr";
    lstPatientAllergies.ValueMember = "ID";
}

//event handler methods that move the items from one list to the other (arrow buttons on the form)
private void btnAddLeft_Click(object sender, EventArgs e)
{
    
    PatientAllergies.Add((RCH.EL.EMR.Allergies)lstAllergies.SelectedItem);
    ResolveAllergies();
    lstAllergies.Refresh();
    lstPatientAllergies.Refresh();
    BindListBoxes();
}

private void btnAddRight_Click(object sender, EventArgs e)
{

    PatientAllergies.Remove((RCH.EL.EMR.Allergies)lstAllergies.SelectedItem);
    ResolveAllergies();
    lstAllergies.Refresh();
    lstPatientAllergies.Refresh();
    BindListBoxes();
}


As you can see, the Lists (not ListBoxes) are of the exact same type, so why the heck isn't the ListBox named lstPatientAllergies not binding properly? By that I mean that I can see that the lstPatientAllergies.DataSource has the proper number of elements and indeed the proper elements, but the lstPatientAllergies.Items is empty and always equals 0.

Ideas?

If the post was helpful, please vote, eh!

Current activities:
Book: Devils by Fyodor Dostoyevsky
Project: Hospital Automation, final stage
Learning: Image analysis, LINQ

Now and forever, defiant to the end.
What is Multiple Sclerosis[^]?

AnswerRe: ListBox won't bind Pin
Henry Minute5-Aug-09 5:04
Henry Minute5-Aug-09 5:04 
GeneralRe: ListBox won't bind Pin
Mustafa Ismail Mustafa5-Aug-09 5:19
Mustafa Ismail Mustafa5-Aug-09 5:19 
GeneralRe: ListBox won't bind Pin
Henry Minute5-Aug-09 5:35
Henry Minute5-Aug-09 5:35 
GeneralRe: ListBox won't bind Pin
Mustafa Ismail Mustafa5-Aug-09 5:38
Mustafa Ismail Mustafa5-Aug-09 5:38 
GeneralRe: ListBox won't bind Pin
Henry Minute5-Aug-09 5:41
Henry Minute5-Aug-09 5:41 
GeneralRe: ListBox won't bind Pin
Mustafa Ismail Mustafa5-Aug-09 5:47
Mustafa Ismail Mustafa5-Aug-09 5:47 
GeneralRe: ListBox won't bind Pin
Mustafa Ismail Mustafa5-Aug-09 5:35
Mustafa Ismail Mustafa5-Aug-09 5:35 
GeneralRe: ListBox won't bind Pin
Henry Minute5-Aug-09 5:38
Henry Minute5-Aug-09 5:38 
QuestionHelp in matching inputted string to a regex pattern Pin
gamer11275-Aug-09 2:05
gamer11275-Aug-09 2:05 
AnswerRe: Help in matching inputted string to a regex pattern Pin
musefan5-Aug-09 2:22
musefan5-Aug-09 2:22 
AnswerRe: Help in matching inputted string to a regex pattern Pin
gamer11275-Aug-09 2:31
gamer11275-Aug-09 2:31 
GeneralRe: Help in matching inputted string to a regex pattern Pin
OriginalGriff5-Aug-09 2:54
mveOriginalGriff5-Aug-09 2:54 
GeneralRe: Help in matching inputted string to a regex pattern Pin
molesworth5-Aug-09 3:07
molesworth5-Aug-09 3:07 
GeneralRe: Help in matching inputted string to a regex pattern Pin
gamer11275-Aug-09 4:00
gamer11275-Aug-09 4:00 
GeneralRe: Help in matching inputted string to a regex pattern Pin
riced5-Aug-09 4:22
riced5-Aug-09 4:22 
GeneralRe: Help in matching inputted string to a regex pattern Pin
gamer11275-Aug-09 4:39
gamer11275-Aug-09 4:39 
GeneralRe: Help in matching inputted string to a regex pattern Pin
riced5-Aug-09 4:44
riced5-Aug-09 4:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.