By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,960 Members | 2,241 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,960 IT Pros & Developers. It's quick & easy.

How DataGridView refresh and update the data source class property run time

P: n/a
I have a class Foo which have two property. I have a thread that do
some process and update class Foo int B. I have a datagridview on main
form. this datagridview data source to this class Foo and column A
binds to string A and column B binds to int B. When i start two
threads, the datagridview able to show two rows and updated int B at
run time. How?

public class Foo
{
public Foo()
{
}

private string a;
public string A
{
set { a = value; }
get { return a; }
}

private int b;
public int B
{
set { b = value; }
get { return b; }
}
}

I try this code, but does not work.

dataGridViewBindingSource.CurrentItemChanged += new
EventHandler(dataGridViewBindingSource_CurrentItem Changed);

void dataGridViewBindingSource_CurrentItemChanged(objec t sender,
EventArgs e)
{
dataGridView.Refresh();
}

Anyone helps. Thanks in advance.

Aug 2 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
For me, normally I bind to arraylist or other collection class then bind
direct to the class. Have a try.

chanmm

"Ivan" <iv*******@gmail.comwrote in message
news:11*********************@p79g2000cwp.googlegro ups.com...
>I have a class Foo which have two property. I have a thread that do
some process and update class Foo int B. I have a datagridview on main
form. this datagridview data source to this class Foo and column A
binds to string A and column B binds to int B. When i start two
threads, the datagridview able to show two rows and updated int B at
run time. How?

public class Foo
{
public Foo()
{
}

private string a;
public string A
{
set { a = value; }
get { return a; }
}

private int b;
public int B
{
set { b = value; }
get { return b; }
}
}

I try this code, but does not work.

dataGridViewBindingSource.CurrentItemChanged += new
EventHandler(dataGridViewBindingSource_CurrentItem Changed);

void dataGridViewBindingSource_CurrentItemChanged(objec t sender,
EventArgs e)
{
dataGridView.Refresh();
}

Anyone helps. Thanks in advance.

Aug 2 '06 #2

P: n/a
Hi Chanmm,

Yes, the Foo class would be BindingList<Foocollections and from the
book Windows Forms 2.0 Programming chapter 16
(http://www.amazon.com/gp/product/032...544016?ie=UTF8)
the Foo should have INotifyPropertyChanged interface so that the data
grid view will update the object class Foo property change.

Now I have another question which across my mind, does DataGridView
suitable to display dynamic multi threading data? just mainly for
viewing static data or non frequent data only? May be the multi
threading method i used does not suitable. I am using background worker
thread. Any comment?

Ivan.

chanmm wrote:
For me, normally I bind to arraylist or other collection class then bind
direct to the class. Have a try.

chanmm

"Ivan" <iv*******@gmail.comwrote in message
news:11*********************@p79g2000cwp.googlegro ups.com...
I have a class Foo which have two property. I have a thread that do
some process and update class Foo int B. I have a datagridview on main
form. this datagridview data source to this class Foo and column A
binds to string A and column B binds to int B. When i start two
threads, the datagridview able to show two rows and updated int B at
run time. How?

public class Foo
{
public Foo()
{
}

private string a;
public string A
{
set { a = value; }
get { return a; }
}

private int b;
public int B
{
set { b = value; }
get { return b; }
}
}

I try this code, but does not work.

dataGridViewBindingSource.CurrentItemChanged += new
EventHandler(dataGridViewBindingSource_CurrentItem Changed);

void dataGridViewBindingSource_CurrentItemChanged(objec t sender,
EventArgs e)
{
dataGridView.Refresh();
}

Anyone helps. Thanks in advance.
Aug 10 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.