PC Review


Reply
Thread Tools Rate Thread

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

 
 
Ivan
Guest
Posts: n/a
 
      2nd Aug 2006
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_CurrentItemChanged);

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

Anyone helps. Thanks in advance.

 
Reply With Quote
 
 
 
 
chanmm
Guest
Posts: n/a
 
      2nd Aug 2006
For me, normally I bind to arraylist or other collection class then bind
direct to the class. Have a try.

chanmm

"Ivan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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_CurrentItemChanged);
>
> void dataGridViewBindingSource_CurrentItemChanged(object sender,
> EventArgs e)
> {
> dataGridView.Refresh();
> }
>
> Anyone helps. Thanks in advance.
>



 
Reply With Quote
 
Ivan
Guest
Posts: n/a
 
      10th Aug 2006
Hi Chanmm,

Yes, the Foo class would be BindingList<Foo> collections 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >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_CurrentItemChanged);
> >
> > void dataGridViewBindingSource_CurrentItemChanged(object sender,
> > EventArgs e)
> > {
> > dataGridView.Refresh();
> > }
> >
> > Anyone helps. Thanks in advance.
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Datagridview how to view a property who is a class ChC2B Microsoft VB .NET 0 3rd Feb 2010 08:21 PM
Sorting column of base class property in DataGridView raises excep Fritz Microsoft C# .NET 0 18th Mar 2009 10:16 AM
Datagridview - necessity not to update the data source =?Utf-8?B?VmluYXkgS2luYWdp?= Microsoft Dot NET Framework Forms 2 9th Oct 2007 03:56 PM
Unable to set the xvalues property of the series class for a single row of source data Sisilla Microsoft Excel Programming 3 11th May 2007 01:34 PM
DataGridView - TextBoxColumn - background update to data source John J. Hughes II Microsoft C# .NET 7 13th Nov 2006 05:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:48 AM.