Button click

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Celine

    Button click

    This question might be very trivial but how can I check that a button
    is clicked. Is there a way to do something like:
    if(button is clicked)
    {
    ....
    }
    Thanks
    Celine
  • AlexS

    #2
    Re: Button click

    Celine,

    why button click event handler cannot do this for you?

    HTH
    Alex

    "Celine" <sqlprob@yahoo. fr> wrote in message
    news:f34b6b7.04 07041358.2d1bdd c6@posting.goog le.com...[color=blue]
    > This question might be very trivial but how can I check that a button
    > is clicked. Is there a way to do something like:
    > if(button is clicked)
    > {
    > ...
    > }
    > Thanks
    > Celine[/color]


    Comment

    • Michael Culley

      #3
      Re: Button click

      "Celine" <sqlprob@yahoo. fr> wrote in message news:f34b6b7.04 07041358.2d1bdd c6@posting.goog le.com...[color=blue]
      > This question might be very trivial but how can I check that a button
      > is clicked. Is there a way to do something like:
      > if(button is clicked)
      > {
      > ...
      > }
      > Thanks
      > Celine[/color]

      If I understand your question, you don't program this way any more. Instead use events. The easiest way to do this is to place a
      button on the form and double click it. The function that is created will be called when someone clicks the button. Put the code you
      want in there.

      --
      Michael Culley



      Comment

      • Peter van der Goes

        #4
        Re: Button click


        "Celine" <sqlprob@yahoo. fr> wrote in message
        news:f34b6b7.04 07041358.2d1bdd c6@posting.goog le.com...[color=blue]
        > This question might be very trivial but how can I check that a button
        > is clicked. Is there a way to do something like:
        > if(button is clicked)
        > {
        > ...
        > }
        > Thanks
        > Celine[/color]

        Assuming you're working in Visual Studio .NET, the click event is the
        default event for a Button object, and you can obtain a proper event
        procedure shell by double-clicking on the button in question, in design
        view.

        private void button1_Click(o bject sender, System.EventArg s e)

        {


        }

        Place the code you want to execute when the button is clicked in this event
        procedure.

        Caveat: this example is from a Windows application where the name of the
        button object is button1.

        Hope this helps.


        --
        Peter [MVP Visual Developer]
        Jack of all trades, master of none.


        Comment

        • R.Balaji

          #5
          Re: Button click

          Hi,

          By default, buttons doesn't store the state information like whether the
          button is clicked or not.

          So declare a boolean private variable.

          In the button click event, set the value for your boolean variable.

          Now you can access the variable and can tell that whether the button is
          clicked or not.

          Regards,
          R.Balaji

          "Celine" <sqlprob@yahoo. fr> wrote in message
          news:f34b6b7.04 07041358.2d1bdd c6@posting.goog le.com...[color=blue]
          > This question might be very trivial but how can I check that a button
          > is clicked. Is there a way to do something like:
          > if(button is clicked)
          > {
          > ...
          > }
          > Thanks
          > Celine[/color]


          Comment

          • Mike Kitchen

            #6
            Re: Button click

            Further to Peter's Explanation I have a very simple event driven app here,
            that shows the code.


            Hope this helps

            Publicjoe
            C# Tutorial at http://www.publicjoe.f9.co.uk/csharp/tut.html
            C# Snippets at http://www.publicjoe.f9.co.uk/csharp/snip/snippets.html
            C# Ebook at http://www.publicjoe.f9.co.uk/csharp/samples/ebook.html

            "Peter van der Goes" <p_vandergoes@t oadstool.u> wrote in message
            news:ua$EmxhYEH A.3644@TK2MSFTN GP12.phx.gbl...[color=blue]
            >
            > "Celine" <sqlprob@yahoo. fr> wrote in message
            > news:f34b6b7.04 07041358.2d1bdd c6@posting.goog le.com...[color=green]
            > > This question might be very trivial but how can I check that a button
            > > is clicked. Is there a way to do something like:
            > > if(button is clicked)
            > > {
            > > ...
            > > }
            > > Thanks
            > > Celine[/color]
            >
            > Assuming you're working in Visual Studio .NET, the click event is the
            > default event for a Button object, and you can obtain a proper event
            > procedure shell by double-clicking on the button in question, in design
            > view.
            >
            > private void button1_Click(o bject sender, System.EventArg s e)
            >
            > {
            >
            >
            > }
            >
            > Place the code you want to execute when the button is clicked in this[/color]
            event[color=blue]
            > procedure.
            >
            > Caveat: this example is from a Windows application where the name of the
            > button object is button1.
            >
            > Hope this helps.
            >
            >
            > --
            > Peter [MVP Visual Developer]
            > Jack of all trades, master of none.
            >
            >[/color]


            Comment

            • Celine

              #7
              Re: Button click

              Thank you all for your answers, it really helped
              Celine

              "R.Balaji" <rbalaji007@hot mail.com> wrote in message news:<OMDwiClYE HA.712@TK2MSFTN GP11.phx.gbl>.. .[color=blue]
              > Hi,
              >
              > By default, buttons doesn't store the state information like whether the
              > button is clicked or not.
              >
              > So declare a boolean private variable.
              >
              > In the button click event, set the value for your boolean variable.
              >
              > Now you can access the variable and can tell that whether the button is
              > clicked or not.
              >
              > Regards,
              > R.Balaji
              >
              > "Celine" <sqlprob@yahoo. fr> wrote in message
              > news:f34b6b7.04 07041358.2d1bdd c6@posting.goog le.com...[color=green]
              > > This question might be very trivial but how can I check that a button
              > > is clicked. Is there a way to do something like:
              > > if(button is clicked)
              > > {
              > > ...
              > > }
              > > Thanks
              > > Celine[/color][/color]

              Comment

              Working...