Hi
I am trying to manage an external dll.
I would like to create an assembly (later exported in a dll) that encapsulates the management of such dll so that it is "easily" usable (I hope!)
I have two different problems so I will split them into different post:
second problem: data binding
I want to have a DataGridView in my form bound to a List into my class
As obvious, I want my DataGridView to show any changes in myList
First test
better but failed again
third test
If I remeber well, in this solution I have the dgv filled with only the column tytle but nothing else
I have also tried to put the BindingSource member into the DllAux class.
I have read that I need to export the INotifyPropertyChanged but I don't know where to put the bs.ResetBinding or how to use it in an efficent way
Somewhere I have read that you can bind everything that exports the IBindingSource interface
No result
I have done so many test in a single afternoon reading so many instruction in internet that I have a lot of confusion in my mind.
Thank you
Davide
I am trying to manage an external dll.
I would like to create an assembly (later exported in a dll) that encapsulates the management of such dll so that it is "easily" usable (I hope!)
I have two different problems so I will split them into different post:
second problem: data binding
I want to have a DataGridView in my form bound to a List into my class
Code:
public class Person
{
private string name = "";
public string Name
{
get { return name; }
private set { name = value; }
}
/// and some other properties
...
}
public class DllAux
{
List<Person> myList = new List<Person>();
void AddPerson(string name)
{
Person p = new Person(name);
myList.Add(p);
}
}
As obvious, I want my DataGridView to show any changes in myList
First test
Code:
public class DllAux
{
public List<Person> myList = new List<Person>();
}
class myForm : form
{
...
DataGridView dgv = new DataGridView();
DllAux DllUse = new DllAux();
...
public frmMain()
{
InitializeComponent();
dgv.AutoGenerateColumns = true;
dgv.DataSource = DllUse.myList; // orrible I know!!
}
}
[code]
failed
Question... If I had used an ArrayList instead of a List<>?
Second test
[code]
public class DllAux : IList<Person>
{
private List<Person> myList = new List<Person>();
...
}
class myForm : form
{
...
DataGridView dgv = new DataGridView();
DllAux DllUse = new DllAux();
...
public frmMain()
{
InitializeComponent();
dgv.AutoGenerateColumns = true;
dgv.DataSource = DllUse;
}
}
third test
Code:
public class DllAux : IList<Person>
{
private List<Person> myList = new List<Person>();
...
}
class myForm : form
{
...
DataGridView dgv = new DataGridView();
BindingSource bS;
DllAux DllUse = new DllAux();
...
public frmMain()
{
InitializeComponent();
bS = new BindingSource(DllUse)
dgv.AutoGenerateColumns = true;
dgv.DataSource = bS;
}
}
If I remeber well, in this solution I have the dgv filled with only the column tytle but nothing else
I have also tried to put the BindingSource member into the DllAux class.
I have read that I need to export the INotifyPropertyChanged but I don't know where to put the bs.ResetBinding or how to use it in an efficent way
Somewhere I have read that you can bind everything that exports the IBindingSource interface
No result
I have done so many test in a single afternoon reading so many instruction in internet that I have a lot of confusion in my mind.
Thank you
Davide