background color question

8 posts, 0 answers
  1. Patxi
    Patxi avatar
    70 posts
    Member since:
    Feb 2009

    Posted 11 May 2009 Link to this post

    Hi,

    it´s a stupid question.

    I don´t know whether I have written in the correct thread, I wanted to write in editor´s thread.

    my question is this. I can´t set a background color to my textbox. I have tried this code snippet but didn´t change its color.

    this.txtName.BackColor = System.Drawing.Color.Yellow; 
     
    Do you know why I can´t change it?

    Thank you
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 May 2009 Link to this post

    Hi Paxti,

    Try the following code and see whether its working fine for you.

    cs:
     
    private void radButton1_Click(object sender, EventArgs e)  
    {  
         ((RadTextBoxItem)this.radTextBox1.TextBoxElement.GetChildrenByType(typeof(RadTextBoxItem))[0]).BackColor = Color.Yellow;   

    You can also refer the following forum link which discusses similar scenario.
    http://www.telerik.com/community/forums/winforms/general-discussions/backcolor.aspx

    Thanks,
    Princy.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 14 May 2009 Link to this post

    Hi guys,

    Princy, thank you for your assistance.

    Patxi, as it is pointed out in the forum link that Princy provided, you can change the BackColor of RadTextBox control by changing the BackColor of its subelements RadTextBoxItem and FillPrimitive:
    this.radTextBox1.TextBoxElement.TextBoxItem.BackColor = Color.Red;  
    ((FillPrimitive)this.radTextBox1.TextBoxElement.Children[1]).BackColor = Color.Red; 

    If you have additional questions, feel free to contact me.

    All the best,
    Nikolay
    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.
  5. Chan
    Chan avatar
    14 posts
    Member since:
    Nov 2012

    Posted 26 Mar 2013 Link to this post

    After invoking these lines i got the following error. How to sort it?

    Error    3    The type or namespace name 'FillPrimitive' could not be found (are you missing a using directive or an assembly reference?)  

    Error    1    'Telerik.WinControls.UI.RadTextBoxControlElement' does not contain a definition for 'TextBoxItem' and no extension method 'TextBoxItem' accepting a first argument of type 'Telerik.WinControls.UI.RadTextBoxControlElement' could be found (are you missing a using directive or an assembly reference?) 


  6. Chan
    Chan avatar
    14 posts
    Member since:
    Nov 2012

    Posted 26 Mar 2013 Link to this post

    After invoking these lines i got the following error. How to sort it?

    Error    3    The type or namespace name 'FillPrimitive' could not be found (are you missing a using directive or an assembly reference?)  

    Error    1    'Telerik.WinControls.UI.RadTextBoxControlElement' does not contain a definition for 'TextBoxItem' and no extension method 'TextBoxItem' accepting a first argument of type 'Telerik.WinControls.UI.RadTextBoxControlElement' could be found (are you missing a using directive or an assembly reference?) 


  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 28 Mar 2013 Link to this post

    Hello Arpus,

    Thank you for writing.

    It seems that you are using RadTextBoxControl not RadTextBox. To change the BackColor of RadTextBoxControl use this code:
    radTextBoxControl1.TextBoxElement.BackColor = Color.Red;

    I hope this helps.

    Kind regards,
    Stefan
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
  8. Chan
    Chan avatar
    14 posts
    Member since:
    Nov 2012

    Posted 29 Mar 2013 Link to this post

    Helo ! Stefan ,

    Thanks a lot it worked !!!
    I have another doubt.

    As u said, u r right i used RadTextBoxControl.
    I used this control to search records (Text box to search records with autocomplete feature).

    Now, i want my autocomplete to be similar as of google search box works.
    like, the moment i started typing text in the textboxcontrol the first matching record should appear as watermark, instead of highlighted and selected.This autocomplete records being pulled from database.

    While typing the text in radtextboxcontrol, the matching characters should be highlighted with bold fonts and the rest characters from matching records should be watermarked.
    For illustration of my problem you may have look on google searchtextbox.

    Looking ahead for your response.

    Thanks,
    Arpus
  9. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 01 Apr 2013 Link to this post

    Hello Arpus,

    Your question is not related to the initial question of this thread - see p4 from our forum rules. Please avoid mixing different subjects in the same thread as this makes it harder for the users to find the information they are looking for. If you cannot find a suitable thread, feel free to open a new one.
     

    Kind regards,
    Stefan
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
Back to Top
UI for WinForms is Visual Studio 2017 Ready