views:

289

answers:

2

Setting RichTextBox as “ReadOnly” doesn't prevent embedded objects (like equations) from being edited by double-clicking them. I could disable the control but then there is a gray background (can't be just changed with BackColor) and no way to scroll. I tried to override OnDoubleClick in a derived class but no success.

A: 

Hmm... Just try setting Sellength to 0 on doubleclick. Isn't there a readonly/locked property?

Cyril Gupta
No. It's going to process double click without mentioning the selection. And as I said “ReadOnly” property doesn't help.
+3  A: 

I found a solution! :) In a derived class:

protected override void WndProc(ref Message m)
    {
        if (m.Msg == 0x0203) // WM_LBUTTONDBLCLK
        {
            // Do nothing
        }
        else
        {
            base.WndProc(ref m);
        }
    }
Interesting solution...
Matthew Scharley