It's not the Click
event handlers acting differently at all. They are both doing exactly the same thing. The difference is that a Button
can receive focus and does when you click it while a PictureBox
cannot and does not. That means that the actions that the grid performs when it loses focus have occurred when your Button
control's Click
handler is executed but not when the Click
event handler for your PictureBox
is executed. If you were to, for instance, click into a TextBox
first and then click the PictureBox
, you'd find the result would be the same as if you had clicked the Button
.
You need to do something to force those actions to occur. Without having tested, I think that calling the EndEdit
method of the grid should be enough. You may need to call the form's Validate
method as well or instead but I'd go with EndEdit
as a first option.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…