?
Solved

Loading a DataGridViewComboBoxCell dynamically via a DataSet?

Posted on 2014-07-29
6
Medium Priority
?
129 Views
Last Modified: 2014-08-04
I am not real sure how to do this but I have a DataGridView that contains a DataGridViewComboBoxColumn. There is only one row in the grid, however, each time this DGV gets loaded, the ComboBox has to be loaded as well. The data in the CB will always be static based on a Database read. Once it's loaded, I need to be able to set it's SelectedValue property based on the same Database read. Any ideas on this?

Thanks!
0
Comment
Question by:BlakeMcKenna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 1000 total points
ID: 40228803
You should be able to bind the column in code:

Dim column As DataGridViewComboBoxColumn = TryCast(dataGridView1.Columns["Manager"], DataGridViewComboBoxColumn)

column.DataSource = SearchResult.FindEmployees()
column.DisplayMember = "Name"
column.ValueMember = "Id"

Open in new window

0
 

Author Comment

by:BlakeMcKenna
ID: 40229080
I'm assuming ["Manager"] is the name of the Column?
0
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 1000 total points
ID: 40229256
Hi BlakeMcKenna;

In answer to your question of Bob, "I'm assuming ["Manager"] is the name of the Column?", the answer is yes. But there is a minor syntax error, it should be ("Manager") in Visual Basic, note that I replaced [ ... ] with ( ... ).
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:BlakeMcKenna
ID: 40229292
I kinda wondered about that! That's C# syntax I believe...

Thanks for the clarification Fernando!
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 40229301
Not a problem BlakeMcKenna, happy to shed some light on the issue.
0
 

Author Closing Comment

by:BlakeMcKenna
ID: 40239139
Thanks guys for your help!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question