-
Aug 7th, 2023, 07:07 PM
#1
Thread Starter
PowerPoster
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.
-
Aug 7th, 2023, 08:28 PM
#2
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.
-
Aug 7th, 2023, 10:21 PM
#3
Thread Starter
PowerPoster
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.
-
Aug 7th, 2023, 10:43 PM
#4
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.
-
Sep 9th, 2023, 02:15 PM
#5
Thread Starter
PowerPoster
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|