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

  • SEARCH
  • Home
  • 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 991667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:08:45+00:00 2026-05-16T06:08:45+00:00

If I want to set the DataSource property on a BindingSource to an IList<>,

  • 0

If I want to set the DataSource property on a BindingSource to an IList<>, do I need an explicit cast as the following error message says or am I doing something wrong?

    interface IView
    {
        IList<OrderItems> BindingSource { get; set;}
    }

    public partial class Form1 : Form, IView
    {
        public Form1()
        {
            InitializeComponent();
        }

        private BindingSource _bindingSource;
        public IList<OrderItems> BindingSource
        {
            get { return _bindingSource; }
            set
            {
                _bindingSource.DataSource = value;
                dataGridView1.DataSource = _bindingSource;                
            }
        }


    }

OrderItems.cs

using System;
using System.Collections.Generic;

namespace Ordering.Data
{
    /// <summary>
    /// Order object for NHibernate mapped table 'Order'.
    /// </summary>
    [Serializable]
    public class OrderItems 
    {
        #region Member Variables
        protected int _id;
        protected Customers _customers;
        protected string _ordername;
        protected DateTime _orderdate;
        protected DateTime? _shipdate;
        protected string _shipvia;
        protected string _shipname;
        protected string _shipaddress;
        protected string _shipcity;
        protected string _shipregion;
        protected string _shippostalcode;
        protected string _shipcountry;
        protected string _status;
        protected DateTime? _lastupdate;
        protected IList<Products> _products;

        #endregion
        #region Constructors

        public OrderItems() {}

        public OrderItems(Customers customers, string ordername, DateTime orderdate, DateTime? shipdate, string shipvia, string shipname, string shipaddress, string shipcity, string shipregion, string shippostalcode, string shipcountry, string status, DateTime? lastupdate) 
        {
            this._customers= customers;
            this._ordername= ordername;
            this._orderdate= orderdate;
            this._shipdate= shipdate;
            this._shipvia= shipvia;
            this._shipname= shipname;
            this._shipaddress= shipaddress;
            this._shipcity= shipcity;
            this._shipregion= shipregion;
            this._shippostalcode= shippostalcode;
            this._shipcountry= shipcountry;
            this._status= status;
            this._lastupdate= lastupdate;
        }

        public OrderItems(Customers customers, string ordername, DateTime orderdate)
        {
            this._customers= customers;
            this._ordername= ordername;
            this._orderdate= orderdate;
        }

        #endregion
        #region Public Properties
        public  virtual int Id
        {
            get { return _id; }
            set { _id = value; }
        }
        public  virtual Customers Customers
        {
            get { return _customers; }
            set {_customers= value; }
        }
        public  virtual string OrderName
        {
            get { return _ordername; }
            set {
                if ( value != null && value.Length > 255)
                    throw new ArgumentOutOfRangeException("value", value.ToString(), "OrderName cannot contain more than 255 characters");
                if (value != this._ordername){_ordername= value;}}
        }
        public  virtual DateTime OrderDate
        {
            get { return _orderdate; }
            set {if (value != this._orderdate){_orderdate= value;}}
        }
        public  virtual DateTime? ShipDate
        {
            get { return _shipdate; }
            set {if (value != this._shipdate){_shipdate= value;}}
        }
        public  virtual string ShipVia
        {
            get { return _shipvia; }
            set {
                if ( value != null && value.Length > 255)
                    throw new ArgumentOutOfRangeException("value", value.ToString(), "ShipVia cannot contain more than 255 characters");
                if (value != this._shipvia){_shipvia= value;}}
        }
        public  virtual string ShipName
        {
            get { return _shipname; }
            set {
                if ( value != null && value.Length > 255)
                    throw new ArgumentOutOfRangeException("value", value.ToString(), "ShipName cannot contain more than 255 characters");
                if (value != this._shipname){_shipname= value;}}
        }
        public  virtual string ShipAddress
        {
            get { return _shipaddress; }
            set {
                if ( value != null && value.Length > 255)
                    throw new ArgumentOutOfRangeException("value", value.ToString(), "ShipAddress cannot contain more than 255 characters");
                if (value != this._shipaddress){_shipaddress= value;}}
        }
        public  virtual string ShipCity
        {
            get { return _shipcity; }
            set {
                if ( value != null && value.Length > 255)
                    throw new ArgumentOutOfRangeException("value", value.ToString(), "ShipCity cannot contain more than 255 characters");
                if (value != this._shipcity){_shipcity= value;}}
        }
        public  virtual string ShipRegion
        {
            get { return _shipregion; }
            set {
                if ( value != null && value.Length > 255)
                    throw new ArgumentOutOfRangeException("value", value.ToString(), "ShipRegion cannot contain more than 255 characters");
                if (value != this._shipregion){_shipregion= value;}}
        }
        public  virtual string ShipPostalcode
        {
            get { return _shippostalcode; }
            set {
                if ( value != null && value.Length > 255)
                    throw new ArgumentOutOfRangeException("value", value.ToString(), "ShipPostalcode cannot contain more than 255 characters");
                if (value != this._shippostalcode){_shippostalcode= value;}}
        }
        public  virtual string ShipCountry
        {
            get { return _shipcountry; }
            set {
                if ( value != null && value.Length > 255)
                    throw new ArgumentOutOfRangeException("value", value.ToString(), "ShipCountry cannot contain more than 255 characters");
                if (value != this._shipcountry){_shipcountry= value;}}
        }
        public  virtual string Status
        {
            get { return _status; }
            set {
                if ( value != null && value.Length > 255)
                    throw new ArgumentOutOfRangeException("value", value.ToString(), "Status cannot contain more than 255 characters");
                if (value != this._status){_status= value;}}
        }
        public  virtual DateTime? LastUpdate
        {
            get { return _lastupdate; }
            set {if (value != this._lastupdate){_lastupdate= value;}}
        }
        public  virtual IList<Products> Products
        {
            get { return _products; }
            set {_products= value; }
        }


        #endregion

        #region Equals And HashCode Overrides
        /// <summary>
        /// local implementation of Equals based on unique value members
        /// </summary>
        public override bool Equals( object obj )
        {
            if( this == obj ) return true;
            if( ( obj == null ) || ( obj.GetType() != this.GetType() ) ) return false;
            OrderItems castObj = (OrderItems)obj;
            return ( castObj != null ) &&
            this._id == castObj.Id;
        }
        /// <summary>
        /// local implementation of GetHashCode based on unique value members
        /// </summary>
        public override int GetHashCode()
        {
            int hash = 57;
            hash = 27 * hash * _id.GetHashCode();
            return hash;
        }
        #endregion

    }
}

Cannot implicitly convert type ‘System.Windows.Forms.BindingSource’ to ‘System.Collections.Generic.IList’. An explicit conversion exists (are you missing a cast?)

  • 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-16T06:08:46+00:00Added an answer on May 16, 2026 at 6:08 am
    return _bindingSource.DataSource as IList<OrderItems>;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using DevExpress LookUpEdit control in my application. I want to set the datasource
I have a List of an object, set to DataSource of a BindingSource, set
I have a data grid view and i set it datasource property as dgvEmployee.DataSource
I want set interfaceOrientation in one UIView as LandscapeLeft and Portrait in other UIView.
i want set the visibility to itemized overlay in map view. if the zoom
I want set Listbox background to transparent but not working Is there any idea?
i want set class for repeater when doPostBack for those dataID i wan but
My question is : I have an EditText and I want set a margin
i have a problem, i want set text of a UILabel or UItextView or
i have a multiple marker Google map, it works fine but i want set

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.