Hi, I have a combo box that takes its values from a database. I need to make unique items in the combobox. I could do this in database part, but I need other attributes of values. Let me explain:

There is Surgery table in my database with id,name and clinic attributes. In combobox, I want to display unique clinic names. At the same time i want to hold multiple surgeries in the clinic in another combobox.

To sum up, How can I display unique attributes of a List.

Thank you

Recommended Answers

All 6 Replies

What I want to do - but cant- is something like that:

foreach (Surgery surg in dbSurgery.get())
            {
                for (int i = 0; i < dbSurgery.get().Count; i++)
                {
                    // if selected surg.clinic has already exist do not display it
                }
            }

How you bind your ComboBox?
Because we may wrap it by custom class and get unique items

commented: nice +5

Tugce is Turkish too :) treat her good Ramy :) i add to your reputation to celebrate my new reputation altering power which is 5.
listen to me if you add to my reputation to make it above 100, by circular reverence i will add to yours and we will both be more reputant.

Welcome to Tugce and every Turkish people here and every where, I said why Serkan gave me reputation points :D now I knew, I've no problem I'll gave you when I celebrate 9th power strength :D
You didn't add on MSN did you still at your job since last message I sent you?

ok i am adding, i forgot to do it.

Thanks for sweet welcomes :)
my solution is like that :

int x = 0;
            foreach (Ameliyatlar amel in dbAmeliyatlar.getir())
            {
 
                bool cntrl = true;

                for (int i = 0; i < x; i++)//kendinden öncekilerle kontrol
                {
                    if (amel.dali.Equals(((Ameliyatlar)(dbAmeliyatlar.getir().ElementAt(i))).dali))
                    {
                        cntrl = false;
                        break;
                    }
                }
                if (cntrl)
                    BolumCmbBox.Items.Add(amel.dali);
                x++;
            }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.