示例#1
0
        public static void PrepareStandardMultilineControl(RichTextBox rtb,
                                                           bool bSimpleTextOnly)
        {
            Debug.Assert(rtb != null); if (rtb == null)
            {
                throw new ArgumentNullException("rtb");
            }

            try
            {
                int nStyle = NativeMethods.GetWindowStyle(rtb.Handle);

                if ((nStyle & NativeMethods.ES_WANTRETURN) == 0)
                {
                    NativeMethods.SetWindowLong(rtb.Handle, NativeMethods.GWL_STYLE,
                                                nStyle | NativeMethods.ES_WANTRETURN);

                    Debug.Assert((NativeMethods.GetWindowStyle(rtb.Handle) &
                                  NativeMethods.ES_WANTRETURN) != 0);
                }
            }
            catch (Exception) { }

            CustomRichTextBoxEx crtb = (rtb as CustomRichTextBoxEx);

            if (crtb != null)
            {
                crtb.SimpleTextOnly = bSimpleTextOnly;
            }
        }
        private void OnPasteCommand(object sender, EventArgs e)
        {
            CustomRichTextBoxEx crtb = (m_rtb as CustomRichTextBoxEx);

            if (crtb != null)
            {
                crtb.PasteAcceptable();
            }
            else
            {
                m_rtb.Paste();
            }
        }