471,610 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

DataGridView in 2005

How to intercept the data from the row's text box before it's written to the
underlying data source. I need to change the edit data before it stored. I
understand that the CellFormating catches the data before it's displayed but
all the other events seem to occur after the system attempts to write the
data back to the data source. I want to handle writing to the data source
directly.

The DataGridView is bound to a data source which seems to preclude using the
VirtualMode option???

A flow chart of when the events occur for this control would be really
helpful.

Regards,
John
Dec 10 '05 #1
3 2663
"John J. Hughes II" <no@invalid.com> a écrit dans le message de news:
Og*************@TK2MSFTNGP12.phx.gbl...

| How to intercept the data from the row's text box before it's written to
the
| underlying data source. I need to change the edit data before it stored.
I
| understand that the CellFormating catches the data before it's displayed
but
| all the other events seem to occur after the system attempts to write the
| data back to the data source. I want to handle writing to the data source
| directly.

Try the CellParsing event

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Dec 10 '05 #2
Yep that did it, thanks a lot. I ended up with this to display allow Hex in
the column.

Set manufactureCodeDataGridViewTextBoxColumn Display format to "X" and then
handle the parsing...

private void dataGridView1_CellParsing(object sender,
DataGridViewCellParsingEventArgs e)
{
if (this.dataGridView1.Columns[e.ColumnIndex].Name ==
"manufactureCodeDataGridViewTextBoxColumn")
{
if (e != null && e.Value != null &&
e.DesiredType.Equals(typeof(Int16)))
{
try
{
/// Convert to a hex value
e.Value = Int16.Parse((string)e.Value,
System.Globalization.NumberStyles.AllowHexSpecifie r);
e.ParsingApplied = true;
} catch{} ///TODO: Add something intelligent here
}
}
}

Regards,
John

"Joanna Carter [TeamB]" <jo****@not.for.spam> wrote in message
news:ul*************@TK2MSFTNGP12.phx.gbl...
"John J. Hughes II" <no@invalid.com> a écrit dans le message de news:
Og*************@TK2MSFTNGP12.phx.gbl...

| How to intercept the data from the row's text box before it's written to
the
| underlying data source. I need to change the edit data before it
stored.
I
| understand that the CellFormating catches the data before it's displayed
but
| all the other events seem to occur after the system attempts to write
the
| data back to the data source. I want to handle writing to the data
source
| directly.

Try the CellParsing event

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer

Dec 10 '05 #3
John

I have been finding several issues with the datagrid that are actually
caused by the the database project being overwritten every time you
compile. It then looks as if the database isnt updating. If you are
having updating issues chech that the Copy if newer property is set and
NOT the "copy always" property of the database file in the project
explorer. However , if you even open the dbase explorer, the timestamp
will be updated and the database will be overwritten again resulting in
data loss.

Check this posting on MSDN:
http://forums.microsoft.com/MSDN/Sho...63741&SiteID=1

Greg

Dec 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Tony K | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by CCCYYYY | last post: by
1 post views Thread by ZEDKYRIE | last post: by

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.