This is a migrated thread and some comments may be shown as answers.

Texbox with different disabled style

12 Answers 619 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
ManniAT
Top achievements
Rank 2
ManniAT asked on 07 May 2008, 02:34 PM
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

12 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 08 May 2008, 04:32 PM
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
0
Jim Miles
Top achievements
Rank 1
answered on 06 Nov 2008, 05:36 PM
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

0
Nick
Telerik team
answered on 07 Nov 2008, 02:15 PM
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.
0
TwoLaJit
Top achievements
Rank 2
answered on 10 Jun 2009, 04:53 AM
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.
0
TwoLaJit
Top achievements
Rank 2
answered on 10 Jun 2009, 05:07 AM
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
0
Peter
Telerik team
answered on 12 Jun 2009, 10:41 AM
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.
0
Guillaume Crétot Richert
Top achievements
Rank 1
answered on 19 Aug 2009, 06:55 PM
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?
0
Peter
Telerik team
answered on 20 Aug 2009, 09:07 AM
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.
0
Guillaume Crétot Richert
Top achievements
Rank 1
answered on 20 Aug 2009, 01:28 PM
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.
0
Peter
Telerik team
answered on 20 Aug 2009, 02:16 PM
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.
0
Guillaume Crétot Richert
Top achievements
Rank 1
answered on 20 Aug 2009, 02:26 PM
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?
0
Peter
Telerik team
answered on 21 Aug 2009, 06:50 AM
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.
Tags
TextBox
Asked by
ManniAT
Top achievements
Rank 2
Answers by
Peter
Telerik team
Jim Miles
Top achievements
Rank 1
Nick
Telerik team
TwoLaJit
Top achievements
Rank 2
Guillaume Crétot Richert
Top achievements
Rank 1
Share this question
or