By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,294 Members | 1,564 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,294 IT Pros & Developers. It's quick & easy.

Odd last character in GetCharIndexFromPosition() on DGV TBcell

P: n/a
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/Sho...23700&SiteID=1
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a

Thanks to Rong-Chun Zhang who gave a solution on MSDN forum:
http://www.microsoft.com/communities...=en-us&m=1&p=1

"Li Qiu" wrote:
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/Sho...23700&SiteID=1
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.