Thanks very much. but how to get the values of "currently editing values"?
I found the following code in the VS.Net help. It uses teh ItemChanged
event of CurrencyManager. What's different from the example you gave which
use the the list property (DataView) of the CurrencyManage cm?
and thus it has different event to handle the data changing. kind of
confused for these two set of events handle something similar...
private void BindControl(DataTable myTable)
{
// Bind A TextBox control to a DataTable column in a DataSet.
textBox1.DataBindings.Add("Text", myTable, "CompanyName");
// Specify the CurrencyManager for the DataTable.
myCurrencyManager = (CurrencyManager)this.BindingContext[myTable, ""];
// Add event handlers.
myCurrencyManager.ItemChanged+=
new ItemChangedEventHandler(CurrencyManager_ItemChanged);
myCurrencyManager.PositionChanged+=
new EventHandler(CurrencyManager_PositionChanged);
// Set the initial Position of the control.
myCurrencyManager.Position = 0;
}
private void CurrencyManager_PositionChanged(object sender,
System.EventArgs e){
CurrencyManager myCurrencyManager = (CurrencyManager) sender;
Console.WriteLine("Position Changed " + myCurrencyManager.Position);
}
private void CurrencyManager_ItemChanged(object sender,
System.Windows.Forms.ItemChangedEventArgs e){
CurrencyManager myCurrencyManager = (CurrencyManager) sender;
Console.WriteLine("Item Changed " + myCurrencyManager.Position);
ClayB said:
Insert & delete actually raise the ListChange event. Here is a litrle
sample. Select a row in the DataGrid and press delete, or start typeing
in the AddNew row in the datagrid. In both cases, ListChanged is hit as
indicated by the Console output to the Output window in the sample.
=====================
Clay Burch, .NET MVP
Visit
www.syncfusion.com for the coolest tools
nick said:
Thanks, any example? Still not clear to figure out how "insert",
"delete" be
triggered by the ListChangedEventHandler....
It does take significant coding to vary cell by cell the fonts and
colors
used in the Windows Forms DataGrid. The upcoming VS2005 release has a
DataGridView class that is much easier to use.
Here is a link that shows how you can use a derived column style to
vary
things now.
http://www.syncfusion.com/faq/winforms/search/927.asp
To catch the insert/delete/update, you can subscribe to the
CurrencyManager.ListChanged event.
CurrencyManager cm = (CurrencyManager)
this.dataGrid1.BindingCOntext[this.dataGrid1.DataSource,
this.dataGrid1.DataMember];
cm.ListChanged += new ListChangedEventHandler(cm_ListChanged);
=============================
Clay Burch, .NET MVP
Visit
www.syncfusion.com for the coolest tools
It seems the datagrid in windows form is not powerful, even for
format.
Is it the only way to create a rich formatting datagrid that using
dynamically created controls in a panel? sounds a lot of work.
Btw, how to capture the insert/delete/update event when using
datagrid?
(because I need customized sql statement to access the database.