[Gtk-sharp-list] Don't do myframe.Add(mylabel) if it was already done

David Griffith dgriffi at cs.csubak.edu
Mon Feb 26 10:03:51 EST 2007


On Mon, 26 Feb 2007, Rafael Teixeira wrote:
> On 2/25/07, David Griffith <dgriffi at cs.csubak.edu> wrote:
> >
> > I'm building a C# app using Stetic.  There's one Notebook widget.  On each
> > page of the Notebook there's an HBox with a VButtonBox at the left.  All
> > the business happens on the right HBox slot.  On the "Management" page, is
> > the "About" button.  Here's the code for the About button:
> >
> > protected virtual void OnAbout(object sender, System.EventArgs e)
> >         {
> >                 Frame myframe = new Frame();
> >                 Label label = new Label();
> >                 myframe.Label = "About Dave's Pizza Helper";
> >                 label.Text = "Dave's App";
> >                 myframe.Add(label);
> >                 ManagementHbox.Add(myframe);
> >                 ManagementHbox.ShowAll();
> >         } // end method OnAbout
> >
> > My problem is that this repeatedly adds myframe to ManagementHbox.  How do
> > I avoid this?

> Just keep a boolean field in the class, set it to true when you first
> add the frame and check it every time to avoid doing it again.
>
> Nevertheless, that is not the way users expect 'about something' to work...
> Guidelines exist to make apps more consistent with each other to the
> benefit of users, but you're free to ignore my remarks.

The objective is to have everything appear in a single window.  The
boolean approach would work, but would require a boolean for each and
every button that causes something to appear in the right HBox slot.  That
doesn't strike me as the Right Way to do this.


-- 
David Griffith
dgriffi at cs.csubak.edu

A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?


More information about the Gtk-sharp-list mailing list