How to get Id from ComboBox in C# windows Form Application
<p>I have a <code>ComboBox</code> filled this way:</p>

<pre><code>List&lt;Category&gt; CategList = new Category().getAllCategory();

foreach (Category cat in CategList)
{            
    ComboForCategory.Items.Add(cat.CategoryName);
}
</code></pre>

<p>The <code>ComboBox</code> displays all <code>CategoryName</code> details successfully... now I need to get <code>CategoryID</code> from selected <code>Name</code>...</p>

<p>Then I used to get <code>CategoryID</code> like this:</p>

<pre><code>Item ob = new Item();
ob.category.CategoryId = ComboForCategory.SelectedValue.ToString();
</code></pre>

<p>But it shows errors. Why? How to get <code>CategoryID</code> from selected <code>Name</code>?</p>