Click here to Skip to main content
15,879,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi every body !

I have a table (WareTable) in SQL Server.

My table has 3 columns: (wareName,SellPrice,Stoke)

I need to use a datagridviwe(=dgw) in my form. datasource = WareTable

In my dgw , 1st column is a ComboBox (WareName).

I want when choose a value in ComboBox , next column (sellPrice) will be filled automatically.

How i can ?
Updated 7-Jun-13 20:55pm

1 solution

Assign a string value to System.Windows.Forms.DataGridViewCell.Value:[^],[^].

You need to be sure that the cell's runtime type is the one which can accept string values; typically, this is System.Windows.Forms.DataGridViewTextBoxCell:[^].

If, by some reason, it needs a check-up, you can simply check up the cell's ValueType then:[^]:
string value = myComboBox.SelectedValue.ToString(); // this is always what is shown in the list part of the combo box
if (myCell.ValueType = typeof(string))
   myCellValue = value;

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900