Getting the index in RichTextBox Control

S

sravan_reddy001

Hi,

I would like to know the index of the position at which the text will
be entered in to RichTextBox.

The index will be used to position the listbox just below it to
suggest the autofill options(intellisense).

The current postion at which the text is entered is not always at the
end. So i want to know the index at which we are entering our text.
 
S

sravan_reddy001

See the SelectionStart and SelectionLength properties.

i did checked them.. but i thought they will be useful only when some
text is selected in that...

<b> IT WORKED.. thanks a lot </b>

Now.. how can i handle the arrow_down & arrow_up keys typed in
richtextbox.Those keys are not generating the KeyPress EVENT..

are there any events that can be raised by these special keys??

Thanks in advance
 
S

sravan_reddy001

Ya.. thanks.. i found out that.. just sometime after posting...

the keydown event is working fine..

slowing improving the project..

Can i ask any questions related to the same project in this thread?

the ideas u were giving is really helpful..

thanks
 
S

sravan_reddy001

Yes,

I'll definitely try to follow the instructions mentioned.
And many many thanks for the suggestion.

I've another problem with my project. When I press the ENTER key(in
the RichTextBox), the selected value in the listbox is added to the
RichTextBox Control. But the enter is also added to the text. How can
I cancel the Event so that the Enter is not typed in.


else if (e.KeyChar.Equals((char)Keys.Enter) || e.KeyChar.Equals((char)
Keys.Space))
{
//add the item only if it is visible and there are
items in it
if (listBox1.Visible == true && listBox1.Items.Count !
= 0)
{
richTextBox1.Select(wordindex, buffer.Length);
richTextBox1.SelectedText =
listBox1.SelectedItem.ToString();
}
buffer = "";
listBox1.Visible = false;
wordindex = richTextBox1.SelectionStart + 1;
e.Handled =
false;
//-> the problem is here. This code is in KeyPress Event of
RichTextBox. i tried Handled Property. It didn't work.
//-> I also used e.Handled and e.SuppressKeyPress = false; in KeyDown
Event.
}

How can I stop Enter and Space from adding to RichTextBox Control.

Thanks in advance
 

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