Solved

Loading a DataGridViewComboBoxCell dynamically via a DataSet?

Posted on 2014-07-29
6
120 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
  • 3
  • 2
6 Comments
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 250 total points
Comment Utility
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
Comment Utility
I'm assuming ["Manager"] is the name of the Column?
0
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 250 total points
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

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

Thanks for the clarification Fernando!
0
 
LVL 62

Expert Comment

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

Author Closing Comment

by:BlakeMcKenna
Comment Utility
Thanks guys for your help!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now