Bill Roper (billroper) wrote,
Bill Roper
billroper

Form-ally Tired of This

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...
Tags: computer, microsoft, musings, tech, work
Subscribe

  • Time for Rebuilding

    Well, there's nothing like research. Having determined that DDR5 is going to carry a substantial price premium over DDR4 memory for at least a year…

  • Driven Wild

    The studio computer continues to misbehave in various ways. When I fired up Cubase today, I got a lot of nasty, blocky video, despite having cleaned…

  • Some Old Doggerel

    I recall having mangled a CSN tune many years ago on the way to Contraption. Like that convention, the particular co-worker whose code I was digging…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments