Solved

Loading a DataGridViewComboBoxCell dynamically via a DataSet?

Posted on 2014-07-29
6
127 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.net and sql server 4 54
No Data for DropDown List 2 32
ASP.NET (VB) return a record 2 52
Visual Basic 6: Code needed for TripleDES Encryption/Decryption 13 40
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.

733 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