Click here to Skip to main content
15,900,378 members
Home / Discussions / C#
   

C#

 
GeneralRe: File IO Permissions Pin
leppie28-May-08 21:31
leppie28-May-08 21:31 
AnswerRe: File IO Permissions Pin
Gareth H28-May-08 3:42
Gareth H28-May-08 3:42 
AnswerRe: File IO Permissions Pin
martin_hughes28-May-08 5:45
martin_hughes28-May-08 5:45 
GeneralRe: File IO Permissions Pin
Lisa Zapson28-May-08 5:55
Lisa Zapson28-May-08 5:55 
QuestionDataGridViewRow Question Pin
Harvey Saayman28-May-08 2:44
Harvey Saayman28-May-08 2:44 
AnswerRe: DataGridViewRow Question Pin
paas28-May-08 4:46
paas28-May-08 4:46 
GeneralRe: DataGridViewRow Question Pin
Harvey Saayman28-May-08 20:52
Harvey Saayman28-May-08 20:52 
QuestionTwo properties in combobox pick list Pin
AndrusM28-May-08 2:12
AndrusM28-May-08 2:12 
I need select from list containing product code and name but show only code in combo textbox.

Tried code below but dropdown list shows only code.
How to display both code AND name in selection list ?

using System.Collections.Generic;
using System.Windows.Forms;

class testForm : Form
{
    testForm()
    {
        ComboBox cm = new ComboBox() { DisplayMember = "DisplayMember", ValueMember = "Code" };
        List<Product> prodList = new List<Product>();
        prodList.Add(new Product() { Code = "001", Name = "Wine", Cb = cm });
        prodList.Add(new Product() { Code = "002", Name = "Beer", Cb = cm });
        cm.DataSource = prodList;
        cm.DataBindings.Add("SelectedValue", prodList, "Code");
        Controls.Add(cm);
    }

    class Product
    {
        public ComboBox Cb;
        public string Code { get; set; }
        public string Name { get; set; }

        public string DisplayMember
        {
            get
            {
                if (Cb.DroppedDown)
                    return Code + " " + Name;
                else
                    return Code;
            }
        }
    }

    static void Main()
    {
        Application.Run(new testForm());
    }
}


Andrus

AnswerRe: Two properties in combobox pick list Pin
JoeSharp28-May-08 2:35
JoeSharp28-May-08 2:35 
GeneralRe: Two properties in combobox pick list Pin
AndrusM28-May-08 23:31
AndrusM28-May-08 23:31 
GeneralRe: Two properties in combobox pick list Pin
JoeSharp28-May-08 23:53
JoeSharp28-May-08 23:53 
GeneralRe: Two properties in combobox pick list Pin
AndrusM29-May-08 3:14
AndrusM29-May-08 3:14 
AnswerRe: Two properties in combobox pick list Pin
carbon_golem28-May-08 2:36
carbon_golem28-May-08 2:36 
Question[Message Deleted] Pin
Sarfraz Munna28-May-08 1:53
Sarfraz Munna28-May-08 1:53 
AnswerRe: Observations between VB.NET and VC#.NET? Pin
Gareth H28-May-08 1:57
Gareth H28-May-08 1:57 
AnswerRe: Observations between VB.NET and VC#.NET? Pin
DaveyM6928-May-08 1:59
professionalDaveyM6928-May-08 1:59 
JokeRe: Observations between VB.NET and VC#.NET? Pin
Vasudevan Deepak Kumar28-May-08 2:43
Vasudevan Deepak Kumar28-May-08 2:43 
AnswerRe: Observations between VB.NET and VC#.NET? Pin
MarkB77728-May-08 2:21
MarkB77728-May-08 2:21 
JokeRe: Observations between VB.NET and VC#.NET? Pin
Vasudevan Deepak Kumar28-May-08 2:42
Vasudevan Deepak Kumar28-May-08 2:42 
AnswerNope. Pin
CPallini28-May-08 2:33
mveCPallini28-May-08 2:33 
QuestionDriver Pin
Pankaj Sardana28-May-08 1:32
Pankaj Sardana28-May-08 1:32 
AnswerRe: Driver Pin
benjymous28-May-08 1:37
benjymous28-May-08 1:37 
AnswerRe: Driver Pin
Sam Xavier28-May-08 23:11
Sam Xavier28-May-08 23:11 
QuestionHow to get a popup in Window Application Pin
Member 369905328-May-08 1:20
Member 369905328-May-08 1:20 
AnswerRe: How to get a popup in Window Application Pin
leppie28-May-08 1:27
leppie28-May-08 1:27 

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.