Solved

C# fill up combobox

Posted on 2014-04-30
2
986 Views
Last Modified: 2016-02-16
Hi Guys ,

I started a new project and I would like to work with the LINQ to ADO.NET Entity Data Model in order to query database from SQl server.

The application built base on widows form application and I would like to fill up some combobox with one of the column I have in the database.

Can somebody provide the code for this.

Also I need some code behind the data grid view to query couple of columns from different table.

Thanks ,
0
Comment
Question by:Moti Mashiah
[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 Comments
 
LVL 16

Accepted Solution

by:
Kalpesh Chhatrala earned 500 total points
ID: 40033921
you can populate combobox like below. cmb1 is combobox object.

var db = new MyDataClass1DataContext();
cmb1.DisplayMember = "MY_TITLE";
cmb1.ValueMember = "MY_ID";
cmb1.DataSource = (from c in db.MY_MASTERs
                        select new { c.MY_ID, c.MY_TITLE }).ToList();

Open in new window

0
 
LVL 1

Author Closing Comment

by:Moti Mashiah
ID: 40034588
Thank you very much I will open another thread for the second question " how to fill up grid from multiple tables.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

628 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