Solved

Loading a DataGridViewComboBoxCell dynamically via a DataSet?

Posted on 2014-07-29
6
126 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
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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
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 …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

825 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