Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 208497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:49:51+00:00 2026-05-11T17:49:51+00:00

I am a little bit puzzled as to how I can optimize my program

  • 0

I am a little bit puzzled as to how I can optimize my program by utlizing DataBindings. My program uses several Linq2SQL bound Objects storing the Data. All ORM objects are stored in a hierarchy. In a second GUI project I am displaying this data in some Text and Combo Box fields.

The data structure hierarchy is as follows:

  • JobManager contains a Dictionary of Jobs
  • Each Job contains a Dictionary of Jobitems
  • Each Jobitem contains exactly one Article

Job, Jobitem and Article each are Linq2SQL objects, representing a ORM.

Now I have a GUI with 2 list views and a tab pane. The tab pane displays the properties of jobs, jobitems and articles and offers the possibility to modify jobs and jobitems. The GUI should behave like this:

  1. When a Job is selected in the first ListView, the related jobitems will be shown in the second ListView and detail information about the job are shown in the tab pane.
  2. When a Jobitem is selected in the second ListView, the jobitem details and article details are shown in the tab pane, but only the Jobitem info is editable.
  3. When changes are done, the user has to intentionally save them. Otherwise the changes should be discarded and not synced to the database.

How can I achieve this behaviour with DataBinding?

Especially, can I bind a complete collection to a single TextField once and shift through its position dictated by the selection in the ListViews? Or do I have to add and remove individual DataBindings on a per Job basis for every selection the user conducts?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:49:51+00:00Added an answer on May 11, 2026 at 5:49 pm

    Do you really mean “Dictionary”? Winform binding is OK with lists (IList/IListSource), but not with dictionary. Additionally, ListView isn’t quite as easy to bind to as some other controls.

    Other than that, it should work purely using the mapping names – I’ll try to do a simple example…


    Edit with basic example from Northwind; note that the data-context should ideally not be long lived; you may also want to look at things like repository implementations rather than direct binding:

    using System;
    using System.Windows.Forms;
    using SomeNamespaceWithMyDataContext;
    static class Program
    {
        [STAThread]
        static void Main() {
            MyDataContext ctx = new MyDataContext();
            BindingSource custs = new BindingSource() {
                DataSource = ctx.Customers};
    
            BindingSource orders = new BindingSource {
                DataMember = "Orders", DataSource = custs};
    
            Button btn;
            using (Form form = new Form
            {
                Controls = {
                    new DataGridView() {
                        DataSource = orders, DataMember = "Order_Details",
                        Dock = DockStyle.Fill},
                    new ComboBox() {
                        DataSource = orders, DisplayMember = "OrderID",
                        Dock = DockStyle.Top},
                    new ComboBox() {
                        DataSource = custs, DisplayMember = "CompanyName",
                        Dock = DockStyle.Top},                
                    (btn = new Button() {
                        Text = "Save", Dock = DockStyle.Bottom
                    }), // **edit here re textbox etc**
                    new TextBox {
                        DataBindings = {{"Text", orders, "ShipAddress"}},
                        Dock = DockStyle.Bottom
                    },
                    new Label {
                        DataBindings = {{"Text", custs, "ContactName"}},
                        Dock = DockStyle.Top
                    },
                    new Label {
                        DataBindings = {{"Text", orders, "RequiredDate"}},
                        Dock = DockStyle.Bottom
                    }
                }
            })
            {
                btn.Click += delegate {
                    form.Text = "Saving...";
                    ctx.SubmitChanges();
                    form.Text = "Saved";
                };
                Application.Run(form);
            }
        }
    }
    

    As an aside – note that the syntax:

    DataBindings = {{"Text", orders, "ShipAddress"}}
    

    Is equivalent to:

    someTextBox.DataBindings.Add("Text", orders, "ShipAddress");
    

    (I only add this as it is a common question)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 186k
  • Answers 186k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer OK, well I didn't manage to get the functionality I… May 12, 2026 at 5:15 pm
  • Editorial Team
    Editorial Team added an answer Use the ioreg command, and grep the received results. A… May 12, 2026 at 5:15 pm
  • Editorial Team
    Editorial Team added an answer We wanted something similar, in "Ant". I am assuming you… May 12, 2026 at 5:15 pm

Related Questions

For a requirement i was asked to export information into a custom entity that
it is a little bit strange to me that boost.asio doesn`t use basic concept
I am a part of a student programming group an we are programming a
I've been reading a fair bit about the performance of using LINQ rather than

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.