How do populate a ContextMenuStrip control using data from a SQL Server 2008 database

Posted on 2011-10-31
Last Modified: 2012-08-13
I have a VS2010 C# Windows application, and I want to add a ContextMenuStrip control to the form. I want to populate the ContextMenuStrip control with data from tables within my SQL Server 2008 database.For example, my ContextMenuStrip will have three menuitems: Projects, Deliverables, and Times. Under each of these items, I want to pull data from the database, and add the data to each menuitem. For Projects, the data will be pulled from "SELECT * FROM dbo.Projects", for Deliverables, the data will be pulled from "SELECT * FROM dbo.Tasks", and for Times, the data will be pulled from "SELECT * FROM dbo.WeekEndingDates". How would I go about doing? Another question I have is: once these menuitems are populated, is there a way to change them upon user selection? For example, if a user selects "Project 1" under the Projects menuitem, can the Deliverables menuitem be repopulated with all the data from the database that is associated with "Project 1"? Example: User selects "Project 1" from Projects menuitem, and then the Deliverables menuitem is populated with "SELECT * FROM dbo.Tasks WHERE Project = 'Project 1'".
Question by:jjliu4492
    1 Comment
    LVL 12

    Accepted Solution


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    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 describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    758 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now