"Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message
news:24f81e8f7cff8c87fb851da87a5@msnews.microsoft.com...
> Perhaps, but your SerialPort object is running under a different thread.
> You need the handler for the DataReceived method to use the form's
> MethodInvoker to do the work (possibly adding the items on the combo box?)
>
> Jim Wooley
>
http://devauthority.com/blogs/jwooley/default.aspx >
>> I added items in the form_Load event of the same for the control is
>> on.
>>
>> "Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message
>> news:24f81e8f7ca58c87fa7f137ca0a@msnews.microsoft.com...
>>
>>> It sounds like you have added the items to the combo box in a thread
>>> other than the one that created the form. Winforms require that
>>> controls on a form can only be accessed via the thread that they were
>>> created under. If you try to access them from another thread, you
>>> will raise an exception. Even if you didn't implicitly create a new
>>> thread, Winforms often have multiple threads working under the
>>> covers.
>>>
>>> In this case, you need to use the form's MethodInvoker method to call
>>> into the thread that the form was created on to have it work with
>>> it's controls. See
>>>
http://msdn2.microsoft.com/en-us/library/system.windows.forms.methodi >>> nvoker.aspx.
>>>
>>> Jim Wooley
>>>
http://devauthority.com/blogs/jwooley/default.aspx >>>>> From the docs for DataReceived event:
>>>>> "The DataReceived event is raised on a secondary thread when data
>>>>> is
>>>>> received from the SerialPort object"
>>>>> You need to marshal your call to the thread that created the
>>>>> combobox. Check out Control.Invoke for more info
>>>>>>>> I get an error message about "Cross threaded operation not
>>>>>>>> valid"
>>>>>>>> I have a combo box on a form and I simply add two items and then
>>>>>>>> want
>>>>>>>> to read
>>>>>>>> the value of the selected item.
>>>>>>>> I don't have any additional threads running?
>>>>>>>> Dim sMsg as string
>>>>>>>>
>>>>>>>> sMsg="The new value is : & Combo1.Text
>>>>>>>>
>>>>>>>> -Lou
>>>>>>>>
>
>