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
Solved

Create a Combo Box in a form that then updates a data grid view

Posted on 2014-11-18
4
176 Views
Last Modified: 2014-11-25
Ok very new to this.  I am using Visual Studio 2013.  I have 3 tables I am working with from a database the database is called GC_Emp_data, the tables are TrainingCourse, Positions, and then Training_Positions.  The training course has a list of all the courses the positions has all positions, and the last table merges the to together via the ID number.  So a training course could be in multiple positions.  What I wanting to do is Select a Training course via a combo box and then it populate a datagridview that will allow me to see what positions that it's has assigned in the (training_posoition table) and also allow me to add new positions to that table.  Not sure where to start and cannot find the right starting point.
0
Comment
Question by:sharris_glascol
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
dustock earned 500 total points
ID: 40450060
You'll need to query your TrainingCourse table to populate your combo box and return a dataset or datatable with the courses.  Then you'll need to provide information for the following to load up the combo box.

            comboBox1.DataSource = //DataSet name or datatablename
            comboBox1.ValueMember = //database column name, probably the course ID
            comboBox1.DisplayMember = //database column name, probably the name of the course

Open in new window


Once you have the combobox populated you'll want to create an event for the selected index changed (double click the combo on your form) so that when a course selection is made you can have your program query the Training_Positions table based on the valuemember of your course selection.  Then return a dataset or datatable with the results and set the datasource of the datagridview to the name of the dataset or datatable

dataGridView1.DataSource = //dataset or datatable name

Open in new window


As far as adding new positions, how were you envisioning you would accomplish that task?  Do you have the pieces in place to be able to connect and query your database from your program or do you need help from the ground up?
0
 

Author Comment

by:sharris_glascol
ID: 40450084
All I want to do is in the datagridview is add positions via a combo box that references the positions table and updates the training/positions table.
0
 
LVL 9

Expert Comment

by:dustock
ID: 40450116
Then you'll need to load a combobox with the list of positions and when you select one and click a button, or just select one you can run an insert statement and then query your database again to get the updated view in your datagridview.  

I can help you accomplish any of this, but I need more information on what you need help with.  The more vague you are in your request the more difficult it is for myself and other experts to assist you.  Do you need help with the code, the queries, the logic?  Do you have any code in place that you've tried but need help to debug?
0
 
LVL 33

Expert Comment

by:it_saige
ID: 40458460
Using what I have understood to be your requirements.  I threw together this quick example in VS2013.  Let me know if this is what you were after.

-saige-
EE-Q28564627.zip
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
T-SQL 10 32
Add a step to a system backup job 6 15
linq, c# 8 22
Shrink multiple databases at once 4 16
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

789 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