Click here to Skip to main content
16,008,299 members
Home / Discussions / C#
   

C#

 
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 
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 
Thank you. I tried the code below but TextBox in combo shows name also.
How to show only code ?

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

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

    class MultiComboBox : ComboBox
    {

        protected override void OnSelectedIndexChanged(System.EventArgs e)
        {
            Product product = (Product)Items[SelectedIndex];
            SelectedItem = product.Code;
            base.OnSelectedIndexChanged(e);
        }

    }

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

        public override string ToString()
        {
            return Code + " " + Name;
        }

    }

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


Andrus

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 
Questionusing timer to switch an alert on and off Pin
steve_rm28-May-08 0:51
steve_rm28-May-08 0:51 
AnswerRe: using timer to switch an alert on and off Pin
leppie28-May-08 1:17
leppie28-May-08 1:17 
QuestionRe: using timer to switch an alert on and off Pin
steve_rm28-May-08 16:15
steve_rm28-May-08 16:15 
QuestionHow do I Convert a byte array to a IPAddress? Pin
Zig15828-May-08 0:32
Zig15828-May-08 0:32 

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.