Click here to Skip to main content
15,879,348 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want datagridview richtextbox cell as richtextbox in editable mode
I made it as editable
I used following code

C#
private void dgvPARs_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
       {

           DataGridView dgvPARsTMD = sender as DataGridView;
           dgvPARsTMD.CurrentCell = dgvPARsTMD[e.ColumnIndex, e.RowIndex];


               RichTextBox temp = dgvPARs.EditingControl as RichTextBox;
       }

Iam getting current editable cell but if entering any special character(i have panel for special charcters) editable row loses its focus

How can i preserve focus of datagridview editable row
Any suggestions
Posted
Updated 12-Mar-14 11:48am
v3
Comments
Dinesh.V.Kumar 12-Mar-14 7:45am    
Try using
RichTextBox temp = (RichTextBox)dgvPARs.FindControl("richtextboxcontrolname");

Hope this helps

Regards,
Sergey Alexandrovich Kryukov 12-Mar-14 12:28pm    
Without seeing your code, it's hardly possible to find out the reason of loosing focus. Normally, it should not happen.
Most likely, your "panel for special characters" grabs the focus, you cannot use it as is.
—SA

1 solution

It's most likely that your panel for "special characters" (none of characters are "special", by the way, but I can understand what you mean) cannot be used in this case, because it grabs the focus.

However, if you need a quick workaround, I have it: Application focus getting and losing[^].

The idea is: as your "special characters" panel grabs focus, you can make it a separate form which is non focusable and not selectable. But then it would be sent to back by your target form. To prevent that, it should also be made "always on top". As you show this panel only temporarily, it should not be a problem. This is just the idea, you can modify this workaround solution to fit your needs.

—SA
 
Share this answer
 
Comments
Maciej Los 12-Mar-14 17:50pm    
+5
Sergey Alexandrovich Kryukov 12-Mar-14 18:08pm    
Thank you, Maciej.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900