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 7008495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:44:33+00:00 2026-05-27T21:44:33+00:00

I have a datagridvew with a bindinglist whose datasource is to an intersection table.

  • 0

I have a datagridvew with a bindinglist whose datasource is to an intersection table. I have an another bindinglist which acts as a lookup and is bound to one of the columns that is a DataGridViewComboBoxColumn type. I have simplified the binding lists as shown below:

public IList<Flight> flights = new List<Flight>()
{
    new Flight { DepartureID = 1, DestinationID = 1, FlightNumber = "101" },
    new Flight { DepartureID = 2, DestinationID = 2, FlightNumber = "202" },
    new Flight { DepartureID = 3}
};

public IList<Departure> departures = new List<Departure>()
{   
    new Departure {ID = 1, City = "Toronto"},
    new Departure {ID = 2, City = "Chicago"},
    new Departure {ID = 3, City = "New York"}
};

public IList<Destination> destinations = new List<Destination>()
{
    new Destination {ID = 1, City = "London"},
    new Destination {ID = 2, City = "Paris"},
    new Destination {ID = 3, City = "Amsterdam"}
};

I have five columns in my datagridview:

  • Depature ID: Textbox
  • Departure: Textbox
  • Destination ID: Textbox
  • Destination: Combobox
  • Flight Number: Textbox

I have three questions:

1) The departures are readonly. I would like to display the ID and the city. How can I add textbox to automatically look up the City value. I thought of the OnCellPainting event and looking it up but the e.Value is readonly. Is there some OnCellDrawing event similar to Delphi.

2) On the combobox for Destinations, once an user selects a value from the combobox, how do I also update the Destination ID also?

3) How do I handle the scenario where I only have values for Departure (e.g. this record (new Flight { DepartureID = 3}) throws an invalid value error because there’s no value for the combobox to lookup)

  • 1 1 Answer
  • 0 Views
  • 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-27T21:44:33+00:00Added an answer on May 27, 2026 at 9:44 pm

    1) The easiest way to set your Departure city would be using a ComboBox like the destination. Binding it to the list of Destinations and marking this column as ReadOnly. This would handle the Departure with no code.

    2) You should bind your DataGridView and your List of flights with a BindingSource. Because your ComboBox ValueMember is your ID and your DisplayMember is the name of the city, it will automatically update your ID.

    3) If you want to bind your data, the template should be the same. You should always have a destination and flight number in your list. If they don’t have value, set them to null. You’re gonna be able to handle the null value while you can’t handle a non-existent attribute.
    new Flight { DepartureID = 3, DestinationID = null, FlightNumber = null }

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

Sidebar

Related Questions

I have a BindingList<T> which is bound to a datagridview. One property in my
I have a DataGridView whose datasource is a BindingList. MyObj has a few nullable
I have a DataGridView which is data-bound to a BindingList. My DataGridView also has
I have a BindingList that I would like to use for a datasource on
So, I have a DataGridView using as datasource a BindingList DataGridView.DataSource = new BindingList<Car>{...}
I have a datagridview where the users can select which subset of columns to
I have a DataGridView bound to a BindingList (C# Windows Forms). If I change
I have a derived DataGridView bound to a BindingList, and the object implements iNotifyPropertyChanged.
I have a worker thread that needs to add items to a BindingList .
I have a DataGridView which I am binding like so: companies = new BindingList<Company>(PersistenceManager.Instance.RetrieveAll<Company>(SessionAction.BeginAndEnd));

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.