473,387 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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
2 4995
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: rob | last post by:
I have a class that among others exposes a string property "Date". The date in this property is stored in the form yyyymmdd. Now I do the following 1) Generate a DataGridViewTextBoxColumn column...
5
by: John Dann | last post by:
I need to display some internal program data in a grid to help with debugging (just display a simple 2D table, not edit or anything else), but I'm not an experienced database coder. AFAICS the only...
7
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's...
1
by: JeremyGrand | last post by:
I've read what's available here, but can't seem to make this work right. I'm experimenting with components on a form, although I'd rather create the pieces & assemble them in code, but that's...
11
by: Kevin | last post by:
I've been searching forever for examples of saving data changes in a DataGridView. There's all kinds of examples, but none really show how to save changes. Someone please help me. I have a...
7
by: John J. Hughes II | last post by:
I have a DataGridView with a TextBoxColumn. I setting the data source to a List<stringvalue in a static class. The list is filled from a background thread. So far all is fine and it works...
2
by: Steve Richter | last post by:
what is the best way to use DataGridView to view data from large database tables? Where the sql select statement might return millions of rows? string connectionString =...
2
by: YouPoP | last post by:
Hi, I have a Window Form to which i added a datagridview. The binding source is working well, but does not update if the database is modified outside the application (i mean not showing the...
20
by: Phil | last post by:
VB2008 I have a DataGridView with MultiSelect = True and SelectionMode=FullRowSelect. One of the columns is a checkbox column. I have a function that goes through all the selected rows and sets...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.