Click here to Skip to main content
15,885,546 members
Home / Discussions / C#
   

C#

 
GeneralRe: Why do not save Login file in Server Explorer Pin
Member 1228884027-Apr-16 4:54
Member 1228884027-Apr-16 4:54 
GeneralRe: Why do not save Login file in Server Explorer Pin
Pete O'Hanlon27-Apr-16 6:29
mvePete O'Hanlon27-Apr-16 6:29 
GeneralRe: Why do not save Login file in Server Explorer Pin
Sascha Lefèvre26-Apr-16 5:40
professionalSascha Lefèvre26-Apr-16 5:40 
GeneralRe: Why do not save Login file in Server Explorer Pin
OriginalGriff26-Apr-16 6:32
mveOriginalGriff26-Apr-16 6:32 
QuestionHelp with Listbox and comboBox Pin
Member 1231776424-Apr-16 23:40
Member 1231776424-Apr-16 23:40 
AnswerRe: Help with Listbox and comboBox Pin
koolprasad200324-Apr-16 23:55
professionalkoolprasad200324-Apr-16 23:55 
GeneralRe: Help with Listbox and comboBox Pin
Member 1231776424-Apr-16 23:56
Member 1231776424-Apr-16 23:56 
AnswerRe: Help with Listbox and comboBox Pin
BillWoodruff26-Apr-16 4:04
professionalBillWoodruff26-Apr-16 4:04 
A few comments:

1. consider the design of displaying the abbreviation for the gender at the end of the name. If you have a synchronized ComboBox/ListBox isn't it enough that your current choice in the ListBox exposes its gender value in ComboBox ?

2. Have you worked with DataBinding these Controls: that's the way to get them synchronized; in WinForms that does have a certain over-head: you may have to reset the binding state as the data type you bind to changes its internal values.

3. Consider using a Dictionary where the Keys are strings, and the Values are either strings or an Enum.
C#
public enum GenderType  // this is Thailand ...
     Indeterminate,
     Ambivalent,
     RefuseToState,
     Male,
     Female,
     Hermaphrodite,
     TransPreOpMToF,
     TransPreOpFToM,
     TransPostOpMToF,
     TransPostOpFToM,
     Eunuch,
     Alien
}

private Array EnumTypeValues { set; get; }
private BindingSource EnumBindingSource { set; get; }

public void SomeMethod(Type enumtype, ComboBox combo)
{
    EnumTypeValues = Enum.GetValues(enumtype);

    EnumBindingSource = new BindingSource();
    EnumBindingSource.DataSource = EnumTypeValues;
    combo.DataSource = EnumBindingSource;
    combo.DisplayMember = "Name";

    combo.SelectedValueChanged += ComboOnSelectedValueChanged;
}

// assuming you've called 'SomeMethod passing the Enum, and a reference to a ComboBox:
// SomeMethod(typeof(GenderType), comboBox1);


private void ComboOnSelectedValueChanged(object sender, EventArgs eventArgs)
{
    GenderType gType = (GenderType) comboBox1.SelectedValue;

    switch (gType)
    {
        case GenderType.Indeterminate: 
            // do something
            break;
        case GenderType.Male:
            // do something else
            break;
        case GenderType.Female:
            // do something else
            break;
        case GenderType.Ambivalent:
            // get Eddie Izzard out of here
            break;
        case GenderType.Alien:
            // call Area 51
            break;
        default:
            break;
    }
   // update other data-structures, or Controls ?
}

«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008

GeneralRe: Help with Listbox and comboBox Pin
Sascha Lefèvre26-Apr-16 5:12
professionalSascha Lefèvre26-Apr-16 5:12 
QuestionHow to get/set SharePoint 2013 MySite properties through API? Pin
Coding Eyes24-Apr-16 23:32
Coding Eyes24-Apr-16 23:32 
AnswerRe: How to get/set SharePoint 2013 MySite properties through API? Pin
Eddy Vluggen25-Apr-16 3:12
professionalEddy Vluggen25-Apr-16 3:12 
QuestionHow to get selected item data of listView Column Item? Pin
0HourCoder23-Apr-16 9:36
0HourCoder23-Apr-16 9:36 
AnswerRe: How to get selected item data of listView Column Item? Pin
Sascha Lefèvre23-Apr-16 9:59
professionalSascha Lefèvre23-Apr-16 9:59 
GeneralRe: How to get selected item data of listView Column Item? Pin
0HourCoder23-Apr-16 10:25
0HourCoder23-Apr-16 10:25 
AnswerRe: How to get selected item data of listView Column Item? Pin
Simon_Whale23-Apr-16 22:24
Simon_Whale23-Apr-16 22:24 
QuestionI have this code that scans the memory of a program, the more programs that precision much memory takes a long time !! Any faster jeito to do this? Pin
Member 1248006323-Apr-16 5:46
Member 1248006323-Apr-16 5:46 
AnswerRe: I have this code that scans the memory of a program, the more programs that precision much memory takes a long time !! Any faster jeito to do this? Pin
OriginalGriff23-Apr-16 5:57
mveOriginalGriff23-Apr-16 5:57 
Questionhow do I get the information from a site of a button? Pin
Member 1248006323-Apr-16 5:12
Member 1248006323-Apr-16 5:12 
QuestionRe: how do I get the information from a site of a button? Pin
CHill6023-Apr-16 5:15
mveCHill6023-Apr-16 5:15 
AnswerRe: how do I get the information from a site of a button? Pin
Member 1248006323-Apr-16 5:28
Member 1248006323-Apr-16 5:28 
AnswerRe: how do I get the information from a site of a button? Pin
OriginalGriff23-Apr-16 5:30
mveOriginalGriff23-Apr-16 5:30 
GeneralRe: how do I get the information from a site of a button? Pin
Member 1248006323-Apr-16 5:35
Member 1248006323-Apr-16 5:35 
GeneralRe: how do I get the information from a site of a button? Pin
CHill6023-Apr-16 5:38
mveCHill6023-Apr-16 5:38 
GeneralRe: how do I get the information from a site of a button? Pin
OriginalGriff23-Apr-16 5:44
mveOriginalGriff23-Apr-16 5:44 
GeneralRe: how do I get the information from a site of a button? Pin
Member 1248006323-Apr-16 5:46
Member 1248006323-Apr-16 5:46 

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.