I need an example spread working with entity framework 4.0 en VS 2010

Posted by: jrfito on 8 September 2017, 2:28 pm EST

  • Posted 8 September 2017, 2:28 pm EST

    I need an example spread working with entity framework 4.0 en VS 2010

    And need it link  to BindingManagerBase to move across sheet.

     

    Tkz.

  • Replied 8 September 2017, 2:28 pm EST

    Hello,

    You can sue the code somehow like this as given below:-

            DataSet ds;

            BindingManagerBase myBindingManagerBase;

            public bindingManagerBase()

            {

                InitializeComponent();

            }

     
            private void bindingManagerBase_Load(object sender, EventArgs e)

            {

                string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\stduser\\Desktop\\Northwind.mdb";

                OleDbConnection con = new OleDbConnection(connectionString);

                string qstringCustomers = "SELECT * FROM Customers";

                string qstringOrders = "SELECT * FROM Orders";

                ds = new DataSet();

                OleDbDataAdapter adapterCustomers = new OleDbDataAdapter(qstringCustomers, con);

                OleDbDataAdapter adapterOrders = new OleDbDataAdapter(qstringOrders, con);

     
                adapterCustomers.Fill(ds, "Customers");

                adapterOrders.Fill(ds, "Orders");

     
                DataRelation customerToOrders = new DataRelation("CustomersToOrders", ds.Tables["Customers"].Columns["CustomerID"], ds.Tables["Orders"].Columns["CustomerID"]);

                ds.Relations.Add(customerToOrders);

     
                fpSpread1.Sheets[0].DataSource = ds;

                GetBindingManagerBase();

            }

            private void GetBindingManagerBase()

            {

                myBindingManagerBase = this.BindingContext[ds, "Customers.CustomersToOrders"];

     
                // Adds delegates to the CurrentChanged and CurrentItemChanged events.

                myBindingManagerBase.CurrentChanged += new EventHandler(myBindingManagerBase_CurrentChanged);

                myBindingManagerBase.CurrentItemChanged += new EventHandler(myBindingManagerBase_CurrentItemChanged);

            }

            void myBindingManagerBase_CurrentItemChanged(object sender, EventArgs e)

            {

                fpSpread1.Sheets[1].Cells[0, 0].Value = fpSpread1.Sheets[0].Cells[2, 2].Value;

            }

            void myBindingManagerBase_CurrentChanged(object sender, EventArgs e)

            {

                // Prints the new value of the current object.

                listBox1.Items.Add("Current Changed ");

            }

    Hope you will find it helpful. Thanks

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels