473,386 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Odd last character in GetCharIndexFromPosition() on DGV TBcell

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
1 2410

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: josh dismukes | last post by:
/// here is the code i'm getting a parse error on the last line of the code which /// is </html> any help will be much appreciated. <?php session_start ();
4
by: Charles Erwin | last post by:
Is there any way, upon scanning in a file line by line to avoid missing the last line if there is not a newline character (aka you have to hit return on the last line of input in your file). I was...
3
by: yxq | last post by:
Hello, The XP Desktop clean wizard can get the last access time of desktop shortcut, i found that the info come from ...
4
by: Andyza | last post by:
I'm using FileSystemObject to open and write to a tab delimited text file. First, I connect to a database and select some data. Then I create the text file and insert each record in the text...
2
by: Sharkie | last post by:
I'm relatively new to XSLT, having strong background in bunch of other programming languages (Perl, Java, etc.). I'm writing an XSLT stylesheet, converting XML into HTML. Everything works just...
6
by: Daniel Mark | last post by:
Hello all: I have the following snippet: In : fileName = 'Perfect Setup.txt\n' In : fileName = fileName # remove the '\n' character In : fileName Out: 'Perfect Setup.txt'
9
by: ice | last post by:
Hello, I have a couple of tables. The client tables and the contacted tables. I am not sure how to start on this, what I need is a way to query all my clients then show any client that the...
4
by: Rasputin | last post by:
Hello, The topic of this question is somewhat related to my previous question, but I wasn't sure if it diserved its own thread. In case of doubt... I double threated. If it's not OK let me...
5
by: dudeja.rajat | last post by:
Sorry : Earlier mail had a typo in Subject line which might look in-appropriate to my friends Hi, I've a list some of whose elements with character \. I want to delete this last character...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.