where is the cursor in a rictextbox???

  • Thread starter Thread starter bany
  • Start date Start date
B

bany

hello,

(sorry for my english...)

I would like know if it's possible to get the position of the cursor( text
and not a mouse position!)

example: line 15, colonne 7 in my richtextbox...

thank for your help

Jean Jacques
 
Jean Jacques,

I doubt that this functionality would actually make sense. If you think
about it, as this is a rich text box, the text can be different font and
sizes for each character. Therfore there can not be a persistant definition
of 'column' . Therfore I would not expect any in built function to exist.

However, you could write something yourself I suppose.

Regards - OHM
 
* "One Handed Man said:
I doubt that this functionality would actually make sense. If you think
about it, as this is a rich text box, the text can be different font and
sizes for each character.

Mhm... It makes sense in a code editor, for example something like
VS.NET's code editor.
 
* "bany said:
(sorry for my english...)

I would like know if it's possible to get the position of the cursor( text
and not a mouse position!)

example: line 15, colonne 7 in my richtextbox...

P/invoke on 'SendMessage' + 'EM_LINEFROMCHAR'/'EM_EXLINEFROMCHAR'.
Sorry, I don't have a sample and an idea for getting the column number
(but there is a way to do that).
 
In the code editor, the characters are ll in the same fonr and size.

Regards - OHM
 
* "One Handed Man said:
In the code editor, the characters are ll in the same fonr and size.

Yep. And you can select a font like Courier New in a RichTextBox too.
 
I know but you are inlikley to mix fonts and sizes, be realistic !



* "One Handed Man [ OHM ]"
In the code editor, the characters are ll in the same fonr and size.

Yep. And you can select a font like Courier New in a RichTextBox too.
 
* "One Handed Man said:
I know but you are inlikley to mix fonts and sizes, be realistic !

Some text editors are based on the RichTextBox control...
 
I still maintain that a column by definition is a vertical line. Therfore,
'column' does not apply if they text is not lined up. If you were to say
row, this also does not apply in a RTB, because lines are wrapped, therefore
the definition of 'Row' does not apply in a RTB who's lines may wrap.


OHM



* "One Handed Man [ OHM ]"
I know but you are inlikley to mix fonts and sizes, be realistic !

Some text editors are based on the RichTextBox control...
 
* "One Handed Man said:
I still maintain that a column by definition is a vertical line. Therfore,
'column' does not apply if they text is not lined up. If you were to say
row, this also does not apply in a RTB, because lines are wrapped, therefore
the definition of 'Row' does not apply in a RTB who's lines may wrap.

You can turn off line wrapping. That's not the problem. Even if there
was line wrapping and different fonts, (idx_x, idx_y) can be used to
specify the position of a character.
 
OK, lets say I give in on the 'Row' , a Colum is still a column. Even if
the fonts are the same, fonts which support Kerning would skew the colum
depending on the letters used.

Loosely speaking you may get "Almost Columns", but it would be better to
refer to horizontal position, not Column Number.

noun [C]
1 one of several vertical blocks of print into which a page of a newspaper
or magazine is divided:
I didn't have time to read the whole article - just the first column.


OHM
 
* "One Handed Man said:
OK, lets say I give in on the 'Row' , a Colum is still a column. Even if
the fonts are the same, fonts which support Kerning would skew the colum
depending on the letters used.

Loosely speaking you may get "Almost Columns", but it would be better to
refer to horizontal position, not Column Number.

The 3rd character in the line will still remain the 3rd character,
regardless of which font(s) is/are used to display it.
noun [C]
1 one of several vertical blocks of print into which a page of a newspaper
or magazine is divided:
I didn't have time to read the whole article - just the first column.

Mhm... For me, it doesn't matter if we are talking about rows or
columns, I think everybody understands what the OP is referring to.
 
Actually no we dont. How do you know that he did not want to use the RTB in
some other way. he may have wanted to show a maxtrix of values for example.

And yes the 3rd character will remain the 3rd character, however the 3rd
character on the 1st row may not be in the same position as the 3rd
character on the 2nd row. In this case viewing characters 3 would not
result in a column but a skew.

Just like chr 3 remaining chr 3, a column is a column.

ENDS

Regards - OHM

* "One Handed Man said:
OK, lets say I give in on the 'Row' , a Colum is still a column.
Even if the fonts are the same, fonts which support Kerning would
skew the colum depending on the letters used.

Loosely speaking you may get "Almost Columns", but it would be
better to refer to horizontal position, not Column Number.

The 3rd character in the line will still remain the 3rd character,
regardless of which font(s) is/are used to display it.
noun [C]
1 one of several vertical blocks of print into which a page of a
newspaper or magazine is divided:
I didn't have time to read the whole article - just the first column.

Mhm... For me, it doesn't matter if we are talking about rows or
columns, I think everybody understands what the OP is referring to.
 
* "One Handed Man said:
Actually no we dont. How do you know that he did not want to use the RTB in
some other way. he may have wanted to show a maxtrix of values for example.

Mhm... I would not use the RichTextBox to display a matrix.
And yes the 3rd character will remain the 3rd character, however the 3rd
character on the 1st row may not be in the same position as the 3rd
character on the 2nd row. In this case viewing characters 3 would not
result in a column but a skew.
ACK.

Just like chr 3 remaining chr 3, a column is a column.

ENDS

;-)
 
Back
Top