RadTextBoxBase

8 posts, 0 answers
  1. Michal
    Michal avatar
    5 posts
    Member since:
    Oct 2011

    Posted 16 Feb 2012 Link to this post

    I want to create Control inherited from TextBoxBase, but I can't. TextBoxBase has an internal abstract method (getter) called TextBoxItem.get. Is this an error in control? How can I create my own text control with my RadTextBoxItem?
  2. Boryana
    Admin
    Boryana avatar
    330 posts

    Posted 20 Feb 2012 Link to this post

    Hello Michal,

    Thank you for writing.

    The RadTextBoxBase has an abstract RadTextBoxItem getter indeed. This, however is not an issue. The control was designed in such a manner. Would you please let us know how exactly you are customizing RadTextBoxItem? What is the functionality that the item is missing?

    I am looking forward to your reply.

    Kind regards,
    Boryana
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Michal
    Michal avatar
    5 posts
    Member since:
    Oct 2011

    Posted 23 Feb 2012 Link to this post

    For example, sometimes I need to reduce writing space to 3/4 of control with - I do it by send message EM_SetRect to the control (0x00b3) and it doesn't work :( When I override WndProc - there is no action on WM_SetFocus message (0x7), I can't override OnKeyPress method (debugger doesn't stop inside it). And so on...
  5. Boryana
    Admin
    Boryana avatar
    330 posts

    Posted 23 Feb 2012 Link to this post

    Hi Michal,

    Thank you for writing back.

    Have you tried setting Padding to the TextBoxElement, so that is shrinks the size of the nested TextBoxItem? For example, I have set a RadToggleButton that adds/subtracts 100 to/from the Right of TextBoxElement's Padding:
    private void radToggleButton1_ToggleStateChanged(object sender, Telerik.WinControls.UI.StateChangedEventArgs args)
    {
        Padding p = this.radTextBox1.TextBoxElement.Padding;
        if (args.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
        {
            p.Right += 100;
        }
        else
        {
            p.Right -= 100;
        }
        this.radTextBox1.TextBoxElement.Padding = p;
    }

    If this is not what you are after, please share more information regarding your scenario.

    All the best,
    Boryana
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  6. Michal
    Michal avatar
    5 posts
    Member since:
    Oct 2011

    Posted 24 Feb 2012 Link to this post

    There is not what I need :( I need to draw an image on rest space of control, but I don't now how :(
    And another (very big) problem: how to handle WM_Paste (for example) message from this control????
  7. Boryana
    Admin
    Boryana avatar
    330 posts

    Posted 28 Feb 2012 Link to this post

    Hi Michal,

    Thank you for writing back.

    Regarding your first question, please have a look at the following article: http://www.telerik.com/help/winforms/editors-textbox-adding-buttons-to-radtextbox.html. It contains useful information and code samples on how to implement scenario similar to yours.

    Instead of handling WndProc and listening for WM_PASTE message, you should subscribe to the KeyPress event of the TextBoxItem and check if the KeyChar is '\x16'. Here is a sample implementation:
    class MyTextBox: RadTextBox
    {
        public MyTextBox()
        {
            this.textBoxItem.KeyPress += KeyPress;
        }
           
        protected void KeyPress(object sender,System.Windows.Forms.KeyPressEventArgs e)
        {
            switch (e.KeyChar)
            {
                //copy
                case '\x03':
                    break;
                //paste
                case '\x16':
                    break;
                //cut
                case '\x18':
                    break;
            }           
        }
    }

    Let me know whether my suggestions fit your requirements. I am looking forward to your reply.

    Kind regards,
    Boryana
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  8. Michal
    Michal avatar
    5 posts
    Member since:
    Oct 2011

    Posted 02 Mar 2012 Link to this post

    Yes, this article presents what I need, thank you.
    But I'm not satisfied about your solution about WM_Paste message (this is only an example - I want to say there is no method of handling some messages in controls). KeyChar '\x16' is Ctrl-V, but what about Shift+Insert (paste too), popup menu and so on? With handling WM_Paste message I don't have to check multiple condtions...
  9. Boryana
    Admin
    Boryana avatar
    330 posts

    Posted 07 Mar 2012 Link to this post

    Hi Michal,

    Thank you for writing back.

    Unfortunately, there is no other way to handle pasting in a RadTextBox successor. WM_PASTE is a message queued only by a standard MS textbox and you will be able to handle it if you are inheriting from TextBox.

    The only workaround in your scenario is to handle different keys combinations:
    protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
    {
        switch (keyData)
        {
            //paste
            case Keys.Shift | Keys.Insert:
                break;
            //paste
            case Keys.Control | Keys.V:
                break;
            //copy
            case Keys.Control | Keys.C:
                break;
            //cut
            case Keys.Control | Keys.X:
                break;
        }           
        return base.ProcessCmdKey(ref msg, keyData);
    }

    Let me know if you have further questions. I will do my best to assist you.

    Greetings,
    Boryana
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready