bindingsource

ADO.Net databinding bug - BindingSource.EndEdit() changes current position

What is the correct order of processing an insert from a data-bound control using BindingSource, DataSet, and TableAdapter? This is causing me eternal confusion. I have a form that is used to add a new row. Before showing the form, I call: bindingSource.AddNew(); bindingSource.MoveLast(); Upon Save, I call: bindingSource.EndEdit();...

InvalidOperationException on Databinding when removing last item in list.

I'm getting the following message when I try to remove the last item in a datagridview. DataBinding cannot find a row in the list that is suitable for all bindings. I have my binding setup as follows. ExtendedBindingList<MyClass> bl = new ExtendedBindingList<MyClass>(GetDataFromDB()); BindingSource bs = new BindingSource(); bs.Dat...

.NET BindingSource.Filter with regular expressions

hello, i am using a BindingSource.Filter to list only certain elements of the datasource. especially i use it like this a lot: m_bindingSourceTAnimation.Filter = "Name LIKE '" + FilterText + "'"; now my question is, if it is somehow possible to use regular expressions with these filters. i would especially need multiple wildcard (*) ...

Can the DataDource of a BindingSource be a property from and object on the form.

For example: I have an Contact object on the form (see below). Can i set the datasource propery of the BindingSource to be the property Contact.Addresses. The class AddressCollection implements BindingList so there is no issue binding this when not encapsulated by the Contact class. public class Contact : IComparable<Contact>, ICompone...

C# Best way to delete a row from typed dataset bounded by binding source

Hello, C# 2008 SP1. I am deleting a row from a row that is currently selected on a datagridview. I am using a Typed dataset and my datagridview is bounded to a binding source. However, I think my technique is not the best, even though it works. Many thanks for any advice, DataRow[] drDelete; // Get the value of the PK ...

Data Binding fails

I have a form with 30 fields of data on it - mostly TextBox controls displaying string data, but there are 3 dropdownlist comboboxes and one textbox used to display a datetime. I'm using a BindingSource to bind these fields to a custom data object derived from BindingList<>. Depending on the content of the data in the data source, some...

Using a BindingSource in a UserControl

I have a UserControl with multiple fields that I would like to have bound to a BindingSource. I would also like the UserControl to expose some BindingSource property so that it can be dropped on a Form and be bound to the BindingSource on the form. Is there an easy way to do this? I realize that I can rebind all of the controls of the...

Using a non-collection object as a DataSource

Hi, A bunch of dotnet framework components use a DataSource component. I have an object that has a number of settings that can modify the DataSource which it represents. I would like to set this object as the dropdown DataSource of a set of ComboBoxes and DataGridViewComboBoxCells. My problem comes when trying to actually hook the thing...

How to update a BindingSource based on a modified DataContext

In my application, I extract the Data of a Linq To SQL DataContext into a dictionary for easy use like so: Jobs = dbc.Jobs.ToDictionary(j => j.Id, j => j); Then I bind this dictionary to a BindingSource: bsJob.DataSource = jobManager.Jobs.Values.ToList(); I refresh the DataContext and the Dictionary regularly for when new Jobs are ...

How to remove reference from a BindingSource in C# Winforms application?

This is a C# (v3.0) Winforms problem. I have a big object that is associated with a BindingSource. When I have done with this object and the BindingSource, I want to remove the reference from the BindingSource so the object can be released. I used BindingSource.Clear(). But after that, in the memory profiler, I can still see the object ...

BindingSource Refresh

I have 2 classes i.e Customer-Order and Customer class has a reference to a collection of Orders. I use master detail bindingSources. My problem is when i use the lazy load pattern for orders my detail bindingsource is not updated. UI BindingSource1.datasource=GetCustomers(); BindingSource2.DataMember="Orders"; BindingSource2.datasour...

Why BindingSource component cannot see inherited properties?

I have defined classes: public class Parent : IParent { public string ParentText { get { return "ParentText"; } } } public interface IParent { string ParentText { get;} } public class Child : Parent, IChild { public string ChildText { get { return "ChildText"; } } } public interface IChild ...

.Net DataGridViews Bound to Same Binding Source in Different Tab Pages

I have a winform (C# VS2008 .net 3.5) with a Tab Control. Two of the pages on the tab control have Data Grid Views bound to the same Binding Source. This works fine. However, there is a bug with Tab Pages in that Data Grid Views held in Tab Pages always show the first column of the bound table, whether or not it is set to visible at d...

Binding DisplayValue to a different Source than the Control's DataSource

Say I have Tasks and Employees, each with their respective table in the database. There would be a many to many relationship between them, and as such there would be a third table for Assignments. If I create a listbox that is bound to a AssignmentsBindingSource I do not have the name of the employee to display. Is there a way to get ...

Undoing All Changes Since BindingSource's last EndEdit call

Here's the scenario (which uses a BindingSource bound to a DataTable within a DataSet): A user creates a new address book contact, fills in the First and Last name in data-bound controls. He presses Apply, whose event handler calls BindingSource.EndEdit(). He then realizes there was a mistake, and adds an email address. But when he pre...

DataTables and a Binding Source

I am trying to understand the difference between the following 2 examples. First, this is how I currently assign Data to a control in my WinForm App. lkuCounty.Properties.DataSource = Person.CountyList(); lkuCounty.Properties.PopulateColumns(); lkuCounty.Properties.DisplayMember = "CountyName"; lkuC...

Multiple Sources(DataTables) in ONE BindingSource?

This question may reveal my ignorance as a Programmer but I won't know if I don't ask. The BLL/DAL I inherited returns DataTables for everything. Address, Phone, CountyList, StateList, etc... My issue is that on a Given page, say Member, there is multiple DataTables being pulled down but the page gets updated as One. Is there a...

BindingSource controls in WinForms - compared to LINQ , ADO.Net, etc?

I'm fairly new to database programming in WinForms, and have been using BindingSource, DataSet, and TableAdapter controls to display data from an Access database in grid and Component One Chart controls. The app is fairly simple right now - the user selects a row in the grid, and a related set of data points is plotted in the Chart cont...

Synchronizing two BindingSources

I have a form with a DataGridView that opens a details form on a double click. When opening the second form I set it to use the same DataSet instance as the parent form. i now want to make sure the second form is pointing at the same DataRow as the parent as well. At first I just sent in the Position property of the parent form's Binding...

.NET BindingSource Filter syntax reference

Hello, you can use the Filter property of a BindingSource to do SQL like filtering. for example bindingSource.Filter= "Activated = 1" but is there something like a documentation on the exact syntax of this? for example i would like to check if a field is not DBNull, so i tried "Field != NULL" but it gives a syntax error. thanks! ...