Groups | Blog | Home
all groups > vb.net > january 2007 >

vb.net : The amazing, vanishing programmatically-entered data in my DataGridView


Daniel Manes
1/23/2007 7:03:47 PM
I'm trying to automatically enter some data into a row when the user
first enters the row. So I created a RowEnter event handler that
contains several statements like the following:

_dataGrid.Rows(rowIndex).Cells(columnName).Value = newData

When I do this, data actually shows up in the row when I click the row.
But as soon as I tab away or click a button elsewhere on the form, the
data vanishes.

If I hand-enter the exact same data, I don't have this problem at all
(I can click anywhere else on the form and the data remains).

Anyone know what could be causing this?

Thanks,

-Dan
Daniel Manes
1/23/2007 10:05:37 PM
Cor,

I see what you're getting at, but I'm not quite sure how to do this.
The DataBoundItem property for the new row is apprently "Nothing." So I
get a NullReferenceException if I try to set any values. It's as if the
new row hasn't "registered" yet.

Thanks,

-Dan

On Jan 23, 9:22 pm, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
[quoted text, click to view]
Scott M.
1/23/2007 10:10:09 PM
Did this really need to be cross-posted to all these newsgroups? Are you
writing this in C# or VB.NET because you posted to both newsgroups (among
others).


[quoted text, click to view]

Daniel Manes
1/23/2007 10:28:49 PM
Okay, well if I use the DataSource property for the DataGridView, then
I can access the DataRowView for the row and set the values. But it
doesn't solve my problem. If I click or tab away from the form, it
still clears the row.

Any other ideas?

-Dan

[quoted text, click to view]
Cor Ligthert [MVP]
1/24/2007 6:22:36 AM
Daniel,

As you use bounded data, than put your data in the source where your data is
in as you use Microsoft complex data controls.

Cor

"Daniel Manes" <danthman@cox.net> schreef in bericht
news:1169607826.959922.196160@j27g2000cwj.googlegroups.com...
[quoted text, click to view]

AddThis Social Bookmark Button