The amazing, vanishing programmatically-entered data in my DataGridView

  • Thread starter Thread starter Daniel Manes
  • Start date Start date
D

Daniel Manes

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
 
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).
 
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
 
Hi Scott,

I didn't realize cross-posting was bad form. It seemed like my question
was relevant to all four groups, and it was not specific to VB.NET or
C#. I could see readers of any of those groups benefiting from any
answers I get, and I figured getting more people involved in the
discussion would be more likely to result in helpful answers. Please
tell me, What's wrong with that?

Thanks,

-Dan
 
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
 
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
 
Back
Top