Bill Roper (billroper) wrote,
Bill Roper

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

  • Closer To Fine

    So the cabinets went in today, which is good. There are, sadly, two problems. First, there is a measurement glitch which resulted in the cabinets…

  • This and That

    Gretchen felt pretty lousy today in the wake of the COVID shot and spent most of the day huddled under a blanket on the couch. Neither kid ended up…

  • That Was the Day That Was

    We finished packing out the kitchen last night around midnight and got way too little sleep last night. Then it was up early this morning so that the…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded