Odd last character in GetCharIndexFromPosition() on DGV TBcell

L

Li Qiu

Hi,

I am trying to get the inserting position of a string within a
DataGridViewTextBoxCell in editing mode, based on the cursor point position
in selection mode.

I used the method GetCharIndexFromPosition() in class
DataGridViewTextBoxEditingControl.

It was found that the DataGridViewTextBoxEditingControl.X has 3 pixel more
than what the function argument needs; the function argument needs a net
length while the X value in the class starts right from the edge of of the
cell. After deduction of 3, the function works fine for all the charters
except the last one: when the cursor in selection mode was in the left half
fo the font, the function returns the correct index so that the cursor in
editing mode will be set at the left side of the character. And vise versa.
However, for the last character, the editing cursor index would alway be set
to its left no matter which half of the font the selection cursor is on.

I tested the function in a TextBox control, it works the same way.

Is there anyway to get arround this problem.

Thanks in advance,
Li Qiu

P.S.
I posted this question in non managed MSDN forun for 3 days with no answer
yet. Please let me know if it is OK to do so.
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3223700&SiteID=1
 

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