Hello Dear,

Follow the following steps to get the desirable result.

1) Create a dataset with two column ID and Desc
2) now set the valuemember property of combo box with  id and display member
property with desc.

i.e
  combobox1.Displaymember = "ID" ( case Sensitive)
  Combobox1.valuemember = "Desc" ( case Sensitive)

These are the case sensitive if you fetch ID and assign 'id' to display
member. then it will not give any result.


3) Combobox1.DataSource = Datasetname


Now use combobox.selectedvalue property to fetch the id.


Hope it will help you.


Regards
Vaibhav Goel
Sr. Engineer.


On Sun, Mar 7, 2010 at 12:03 AM, ruchita sharma <ruchita.wa...@gmail.com>wrote:

> selected index will give u only the id no. that is taken in combo as a
> control i mean if u write
> combobox1.selectedindex then u will get 1 then 2 then 3 not 1and 2 and 52
> so if u want 1 n 2 and 52 then  bind the value field with this ID and write
> combobox1.text to assign the values of combobox to whomso ever object u want
>
> I hope m right
>
>
> On 3/4/10, 50cal <david_gas...@hotmail.com> wrote:
>>
>> Hey all,
>>
>> I'm trying to achieve the following:
>>
>> Example Data
>> <ID>        <Desc>
>> 1             - "This is number one"
>> 2             - "This is number two"
>> 52           - "this is number three"
>>
>> So as you can see the ID does not always resemble the data, I.E 52 is
>> the third item in the list not the 52nd.
>>
>> I want the description to show in the combo box, but I want the value
>> (ID) to be the value returned.
>>
>> Can this be achieved?
>>
>> Many Thanks,
>> Dave.
>>
>
>
>
> --
>
> Ruchita Sharma
> Software Engineer

Reply via email to