Results 1 to 5 of 5

Thread: Setting the background color of a textbox while in GotFocus()

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Setting the background color of a textbox while in GotFocus()

    I have been out of IT now for about 4.5 years and am just now getting back into it. I'm also learning C#, even though I can read it a little. So my question is in the Title...how to set the Background Color of a textbox while in the GotFocus() event. Here is what I have so far and it's not working.

    Name:  code.jpg
Views: 297
Size:  8.6 KB
    Blake

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    2,900

    Re: Setting the background color of a textbox while in GotFocus()

    That seems overly convoluted.

    Why not just:

    Code:
    FName.BackColor = FocusColor;
    That is assuming that FocusColor is property declared elsewhere in your code.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Setting the background color of a textbox while in GotFocus()

    I tried that but BackColor didn't even show up in the intellisense. Not sure what's going on. In VB.Net, it's pretty much the same code and that works.
    Blake

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    109,998

    Re: Setting the background color of a textbox while in GotFocus()

    There is no such property. The TextBox control in Windows Forms has a BackColor property but you're using WPF, so it's a different class with different members. Seems like you might need to do a bit of research on how WPF controls work.

    I don't really use WPF but I think you would need to set the Background property, but note that it is type Brush.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Setting the background color of a textbox while in GotFocus()

    I don't want to use WPF either...WinForms still works just fine. I've always thought...don't fix what's not broke!
    Blake

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width