View Single Post
  #3 (permalink)  
Old August 21st, 2003, 08:04 AM
Ankur_Verma Ankur_Verma is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

This code works

//declaration of the struct and the class
    struct ValoriNascosti
    {
        public string valstring;
        public int valint;
    };

    class ListItem
    {
        private ValoriNascosti valone;
        private string Desc;

        public ListItem(string strVal,int intVal,string desc)
        {
            valone.valstring = strVal;
            valone.valint = intVal;
            Desc = desc;
        }

        public string getDesc
        {
            get
            {
                return Desc;
            }
        }

        public ValoriNascosti getValone
        {
            get
            {
                return valone;
            }
        }
    };

     .
     .
     .


//filling up
    ArrayList elencoProdotti = new ArrayList();
    elencoProdotti.Add(new ListItem("0001", 5, "Prodotto1"));
    elencoProdotti.Add(new ListItem("0002", 6, "Prodotto2"));
    elencoProdotti.Add(new ListItem("0003", 7, "Prodotto3"));

    this.testcombo.DataSource = elencoProdotti;
    this.testcombo.DisplayMember = "getDesc";
    this.testcombo.ValueMember = "getValone" ;




// usage
    MessageBox.Show(((ValoriNascosti)this.testcombo.Se lectedValue).valint.ToString());

I cannot point out the problem out of what you have described
in your query so just check this code to see if there is
anything I have done differently.

Regards

Ankur Verma
.Net and C++ Specialist
Wiley Tech Support
Reply With Quote