Hey all,
I have following situation in a C# Windows Forms (.NET 4.0) application:
I have a bindingsource which datasource is set to a collection of objects of a custom class.
Most properties of this class can be represented by a textbox or checkbox, as they are strings or numbers or bools. However, there is one property, called Ratings, which is another custom object and must be represented by a custom control I developed.
I have bound a datagridview to the bindingsource, and obviously the dgview displays the numbers, strings and bools correctly. But on the same form I also have an instance of the custom control I developed, and so want I want to do now is bind my custom control to the same bindingsource as the datagridview uses, and to the specific datamember called Ratings. But I don't have the slightest clue on how to start. I suspect I must implement some interface which implements DataSource and DataMember on my control, but not sure where to begin. So basically what I want is each time the selected item is changed by means of selecting another row in the datagridview, the according Ratings property is represented in the custom control.
Right now the endresult that I wish to achieve is working, but I do this by refreshing my custom control each time the OnSelectedRowChanged event of the datagridview is firing, and associating the Ratings property of the selected item to the custom control.
But I was wondering if I could achieve this purely by the databinding mechanism in .NET.
Thanks for any replies !
Mathieu
ps: to further clarify, as it doesn't seem so clear in pure text:
Psuedo-code representing the object that I use as datasource for the bindingsource is:
public class Car
{
private string number;
private string name;
...
private Ratings ratings;
public string Number
{
get { return this.number; }
set { this.number = value; }
}
public string Name
{
get { return this.name; }
set { this.name = value; }
}
...
public Ratings Ratings
{
get { return this.ratings; }
set { this.ratings = value; }
}
}
So I want all the string and number properties from the bindingsource to bind to the datagridview, but I need the Ratings property to bind to the custom control.