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

  • Throw the Squid!

    Yesterday, there was some time after dinner and before sunset, so the temperature being pleasant for a change, Gretchen and I wandered out to the…

  • I'm Going Back To Work, I'm Going Back To Work

    I spent more time today working over designs than coding, but that's ok. Getting the design right makes the coding easier. And more likely to work...

  • Swept

    The weather was relatively cool today, so Gretchen and I went out and spent some time trying to get the garage into a state where it could be cleaned…

  • 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