Ben Voigt [C++ MVP] ha scritto:
>>> I add in a ComboBox.parity some items like:
>>> None
[quoted text clipped - 17 lines]
> (System.IO.Ports.Parity)Enum.Parse(typeof(System.IO.Ports.Parity),
> cmbParity.SelectedItem);
Hi,
I try both code but they don't work
i have this message error
The best overloaded method match for 'System.Enum.Parse(System.Type,
string)' has some invalid arguments
Argument '2': cannot convert from 'object' to 'string'
Jon Skeet [C# MVP] - 30 Jun 2007 10:43 GMT
> I try both code but they don't work
> i have this message error
> The best overloaded method match for 'System.Enum.Parse(System.Type,
> string)' has some invalid arguments
> Argument '2': cannot convert from 'object' to 'string'
So cast cmbParity.SelectedItem to a string in the call...

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
kjqua - 30 Jun 2007 11:30 GMT
Jon Skeet [C# MVP] ha scritto:
>> I try both code but they don't work
>> i have this message error
[quoted text clipped - 3 lines]
>
> So cast cmbParity.SelectedItem to a string in the call...
Thanks now it work
serialPort.Parity =
(System.IO.Ports.Parity)Enum.Parse(typeof(System.IO.Ports.Parity),
cmbParity.SelectedItem.ToString());
marco