Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-11-18
4
Medium Priority
?
190 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
[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
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
dustock earned 2000 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 34

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

721 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