billroper: (Default)
[personal profile] billroper
I've spent a lot of time fighting through the idiosyncrasies of Windows Forms in the last month or so. Today's entertainment was the Browse Edit user control that I wrote and getting the validation to work the way that I wanted it to.

If the user clicks the browse button associated with the edit control, I want to allow the form that contains the control to pop an arbitrary dialog to collect the information. That turns out to be not too difficult once you get the EventHandler information set up correctly.

The problem was that I wanted to populate the edit control and validate it immediately if you hit the OK button in that arbitrary dialog, but not if you hit the Cancel button. Populating the edit control was easy. Triggering validation wasn't.

Until I finally figured out that my event handler function for the browse button in the Browse Edit control class could then call the function also in the Browse Edit control class that looks for a validation handler supplied by the parent form, because that will actually do what I wanted. If I check to make sure that I've stuffed text in the edit control, that is.

*thud* *thud* *thud*

Well, that only took a couple of hours to sort out...
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

Profile

billroper: (Default)
billroper

April 2025

S M T W T F S
   1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 2223242526
27282930   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Apr. 23rd, 2025 04:19 pm
Powered by Dreamwidth Studios