Behavior of the DataGrid while closing the application

S

schaf

Hi NG!
I have recognized a strange behavior of the DataGrid control.
If I'm editing the value of a cell in the DataGrid and press the
close
button (of the ControlBox of the application 'X') then the
application
closes but the DataGrid does not loose the Focus. I would like to
save
the changes done in the corresponding cell.

How can I check if I have to save the value in the data grid?


regards
Marcel
 
M

Marc Gravell

Can you switch to DataGridView? This appears to be fixed, as
demonstrable by adding the following to my last post:

(add the bottom of the ctor)
DataGridView dg = new DataGridView();
dg.Dock = DockStyle.Fill;
dg.DataSource = new SomeData[] { data };
Controls.Add(dg);
dg.BringToFront();

(add to the class)
protected override void OnClosing(CancelEventArgs e) {
e.Cancel = MessageBox.Show(this, data.Name + " : " +
data.Size, "Closing", MessageBoxButtons.OKCancel,
MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) ==
DialogResult.Cancel;
}

With DataGridView you see the new values in the message-box,
suggesting that updates and validation have occurred; with DataGrid
you get (as you posted) the old values.

Marc
 
S

schaf

Can you switch to DataGridView?
No because I'm working on .NEt 1.1
But I have obtained help from the net and the easiest way to solve the
problem is to change the focus of the control in the Closing event.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top