• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 56
  • Last Modified:

How select an item by code from a datagridviewcombobox

I'm using vb.net 2013. I'm trying to select a item from a DataGridViewComboColumn. I have jet all data charged, and manually working, but I need select some ones by code. Any idea?

For example, I have a list o ten names (as display member) and each ones with an id (as valuemember). I want to select by code an id to show the name.


Gonzalo Tomasello
Gonzalo Tomasello
  • 2
1 Solution
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You should be able to set the SelectedIndex of the combobox column:

YourDGV.CurrentRow.Cells("YourComboBoxColumnName").SelectedIndex = YourValue

Assuming, of course, that the ValueMember is the same as "YourValue".

Gonzalo TomaselloAuthor Commented:
Thanks, I finally solve the problem. It was a Type mistake. I sent to the DGV.value a number without type. The ValueMember is a long number type, then when I pass a long number the problem solve by itself...

Gonzalo TomaselloAuthor Commented:
solve my problem, and work properly now...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now