Texbox with different disabled style

13 posts, 0 answers
  1. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 07 May 2008 Link to this post

    Hi,

    while some of your controls have a "UseDefaultDisabledPaint" property I can't find this on RadTextBox.

    My need:
    I hav a data entry application.
    Left I have a list of items - and on the right the details of it.
    The user can edit the details by pressing a button which enables the controls (textboxes and so on).

    For better visibility it would be great to have a special style on disalbed Textboxes.

    By the way -  the only reason to use RadTextBox instead of Forms.Textbox is the idea to use styles for better visiblity.
    Because I see no other reason -- it's more oposite! With Forms.Textbox SHIFT-TAB works!!

    So is there a way to change the disabled style?
    Even having BLACK as ForeColor would be enough!

    Regards

    Manfred
  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 08 May 2008 Link to this post

    Hi Manfred,

    Thank you for writing.

    The
    UseDefaultDisabledPaint is located in RadTextBoxElement RootElement.

                RadTextBox
    radTextBox = new RadTextBox();
               
    radTextBox
    .RootElement.UseDefaultDisabledPaint = false;

    Also you could set the back color using the TextBoxItem whenever you change the Enabled state of the RadTextBox. In the code I used to verify this behavior, I had a button change the Enabled state of the RadTextBox. Here's the click handler of the button, that set the back color, according to the state of the textbox:


            private void radButton1_Click_1(object sender, EventArgs e)  
            {  
                radTextBox1.Enabled = !radTextBox1.Enabled;  
     
                if (!radTextBox1.Enabled)  
                    ((RadTextBoxItem)radTextBox1.RootElement.Children[0].Children[0]).BackColor = SystemColors.Control;  
                else 
                    ((RadTextBoxItem)radTextBox1.RootElement.Children[0].Children[0]).BackColor = enabledBackColor;  
            } 

    I hope that helps. Please write me back if you have more questions.

    Sincerely yours,
    Peter
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jim Miles
    Jim Miles avatar
    22 posts
    Member since:
    May 2006

    Posted 06 Nov 2008 Link to this post

    Hi,

    I'm visiting here to find out why a simple myRadTextBox.BackColor doesn't work.  I found my answer.  Not sure why it wouldn't work like "normal".  I changed some of my textboxes to Microsoft's controls just to make sure I wasn't losing my mind.  Is there a reason it doesn't work?  It's always white, even if you change BackColor in the form designer.

    I love your web controls, but the window controls can be a bit frustrating sometimes.

    For anybody else that stumbles upon this, here's a little VB routine to make your code read better...

        Sub setBGColor(ByVal tb As RadTextBox, ByVal c As Drawing.Color)
            DirectCast(tb.RootElement.Children(0).Children(0), RadTextBoxItem).BackColor = c
        End Sub





    -jim

  5. Nick
    Admin
    Nick avatar
    767 posts

    Posted 07 Nov 2008 Link to this post

    Hi Jim Miles,

    Thank you for sharing your code with the community! Your points have been updated.

    Sincerely yours,
    Nick
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. TwoLaJit
    TwoLaJit avatar
    38 posts
    Member since:
    Nov 2006

    Posted 09 Jun 2009 Link to this post

    This has to be a bug? Can this be fixed in the next version or update?
    when setting a field to readonly = true. the background color of the textbox should be grayed out.
  7. TwoLaJit
    TwoLaJit avatar
    38 posts
    Member since:
    Nov 2006

    Posted 10 Jun 2009 Link to this post

    when i set enabled = false
    then i do notice the boarder change subtley but I need the background to change under readonly = true like with the microsoft controls
  8. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 12 Jun 2009 Link to this post

    Hello TwoLaJit,

    We do not support this scenario yet and the Background color in this case should be set manually (using the function posted from Jim).

    Sincerely yours,
    Peter
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. Guillaume Crétot Richert
    Guillaume Crétot Richert avatar
    33 posts
    Member since:
    Oct 2008

    Posted 19 Aug 2009 Link to this post

    Hi!

    I would like my "Disabled" behavior to make the TextBox appear like a label. I was able to hide the Borders and some of the fill of the textbox with various ShouldPaint = False, but I'm unable to display only the TextBox's text. I tried Jim's code to set the BackGroundColor to Transparent, but there is still a region of white around my text.

    What should I do?
  10. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 20 Aug 2009 Link to this post

    Hello Guillaume Crétot Richert,

    Thank you for writing. Yes, it is possible to remove the region of white around the text. Please, refer to the code snippet:

    this.radTextBox1.TextBoxElement.TextBoxItem.BackColor = Color.Red; 
    this.radTextBox1.TextBoxElement.Children[1].Visibility = Telerik.WinControls.ElementVisibility.Hidden;//this line hide the fill arround the text 
    this.radTextBox1.TextBoxElement.Children[2].Visibility = Telerik.WinControls.ElementVisibility.Hidden;//this line hide the border arround the text 

    I hope this helps.

    All the best,
    Peter
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  11. Guillaume Crétot Richert
    Guillaume Crétot Richert avatar
    33 posts
    Member since:
    Oct 2008

    Posted 20 Aug 2009 Link to this post

    That did not work, I'm still seeing a white rectangle around the text. I can show you a picture, or even send you the project to show you.
  12. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 20 Aug 2009 Link to this post

    Hi Guillaume Crétot Richert,

    Please refer to the attached project. You should add these lines of code after calling InitialInitializeComponent.

    Sincerely yours,
    Peter
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  13. Guillaume Crétot Richert
    Guillaume Crétot Richert avatar
    33 posts
    Member since:
    Oct 2008

    Posted 20 Aug 2009 Link to this post

    I see the problem: the white doesn't disappear, you just set it to the background color of the container control. My textboxes appear on RadPanels that have a gradient, so your technique would be very hard to apply for me, because my backcolor is not uniform. I tried using Color.Transparent as well, but that did not work, even in your project.

    Are there any plans to support transparency?
  14. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 21 Aug 2009 Link to this post

    Hi Guillaume Crétot Richert,

    RadTextBox control (respectively RadTextBoxElement) uses internally the standard TextBox control. This means that RadTextBoxElement has the same limitations as the TextBox and it doesn't support transparent control. Please, excuse us for the inconvenience. Don't hesitate to contact us if you have other questions.

    All the best,
    Peter
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
Back to Top
UI for WinForms is Visual Studio 2017 Ready