Hi,
Today, I encountered two problems with RichTextBox while writing a text
editing module. Hope that some expert here can help me solve these.
First, I'm catching the KeyDown event of RichTextBox, specifically the
Ctrl-B, Ctrl-I and Ctrl-U keys, to enable users to format text using those
shortcuts. Ctrl-B and Ctrl-U works properly. However, for the Ctrl-I,
RichTextBox automatically interprets it as a TAB character. Therefore, when
users press Ctrl-I, RichTextBox inserts a Tab character before calling my
event handlers. How can I prevent RichTextBox from recognizing Ctrl-I as TAB
character, but still allowing my event handler to be called ? I tried to
override the ProcessCmdKey() method, but that disables my event handlers
altogether.
Second, I'm implementing drag & drop for my RichTextBox. I want to let users
drag formatted text (e.g. from Word) into my RichTextBox too. In my DragDrop
event, I detect the presence of Rtf format from the IDataObject. If it's
there, I insert the Rtf data into my RichTextBox.Rtf property. However, this
approach doesn't work. If I add the normal text data into RichTextBox.Text
property, it works. I think I'm missing something on the Rtf side. Anyone can
help shed some light on this ?
Thanks in advance.
Dotnetjunky