How can I make a button that can sendkeys into a datagridview (so I need to somehow return datagridview to its state prior to it losing focus)
I'll explain the problem
I have a form with a datagridview and some buttons
I can click the button and it will enter the corresponding letter,
dataGridView1.Focus();
SendKeys.Send("a"); //or m or z, depending on the text of the button.
The button is meant to be for entering data into datagridview. I could make it so it's enabled only when datagridview's enter method is called. When the button is clicked then the datagridview loses focus so I have to give it the focus again, prior to sending the key. Hence the two lines above.
I want the user to be able to use the buttons to enter data into datagrid.
The problem is, let's say I want the user to be able to enter the text "maz" I can't do it. I only get an individual a or m or z. And even if I could put a cell back into editable mode, i'd need to remember where the cursor was.. So if somebody typed asdf into a cell and put the cursor between d and f, and clicked m, i'd want it to say asdmf.
I don't know how to accomplish that.
I have an idea.. that maybe if there was a way of registering that the mouse was over a button and the click was pushed, but without losing focus on datagridview, then that would be one way that it could be done. I don't know how to do that though, and i'm interested in different ways.