Set Combobox’s SelectedValue in DataGridview

To set SelectedValue in ordinary combobox, you can select from properties easily.

But … after binding DataTable into datagridview, I had no ideas what to do.

I thought it would be helpful for coding, so I put it here.

You can download the file from here that I created.

How to Set Combobox in DataGridview’s Selectedvalue

Here is how to code.

DatagridView[column, row].Value = intSelectedValue;

Only this.

I was looking for the “Selected blah-blah-blah” property of the datagridview ,so I could not find.

In the combobox of the datagridview, SelectedValue does not exist

We need to use value of “ValueMember” instead.

Sample Code(Set to Combobox of DataGridview)

When form loading

Set ValueMember and DisplayMember to combobox into datagridview when form loading.

When the button pressed

When the button is clicked, the number entered in the textbox is reflected to ValueMember (SelectedValue) of the combobox.



メールアドレスが公開されることはありません。 * が付いている欄は必須項目です