Solved

Loading a DataGridViewComboBoxCell dynamically via a DataSet?

Posted on 2014-07-29
6
128 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 250 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 250 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…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

729 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