Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Grid View Event..

Grid View Event..

Scheduled Pinned Locked Moved C#
csshelp
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rahul DSG
    wrote on last edited by
    #1

    i am working in a window Application and using a Gridview.In this gridview i am adding a button but can't find Button_Click Event... Plz Dont tell me about Cell_click Event.Its Not working Properly... Need A Help.. Thanks

    M D H K 4 Replies Last reply
    0
    • R Rahul DSG

      i am working in a window Application and using a Gridview.In this gridview i am adding a button but can't find Button_Click Event... Plz Dont tell me about Cell_click Event.Its Not working Properly... Need A Help.. Thanks

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      You say you are working in a Windows application - I presume you mean a winforms application, there is no GridView in winforms. If you are working on a webform then you will get a better response in the ASP forum. The event I get for a DataGridView button on the other had is

      private void dgData_CellContentClick(object sender, DataGridViewCellEventArgs e)
      {

      	}
      

      Never underestimate the power of human stupidity RAH

      R 1 Reply Last reply
      0
      • M Mycroft Holmes

        You say you are working in a Windows application - I presume you mean a winforms application, there is no GridView in winforms. If you are working on a webform then you will get a better response in the ASP forum. The event I get for a DataGridView button on the other had is

        private void dgData_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        	}
        

        Never underestimate the power of human stupidity RAH

        R Offline
        R Offline
        Rahul DSG
        wrote on last edited by
        #3

        ok thats DataGridView..is there any event by i can handle the button event ...

        1 Reply Last reply
        0
        • R Rahul DSG

          i am working in a window Application and using a Gridview.In this gridview i am adding a button but can't find Button_Click Event... Plz Dont tell me about Cell_click Event.Its Not working Properly... Need A Help.. Thanks

          D Offline
          D Offline
          deepseeindeepsy
          wrote on last edited by
          #4

          CellContentClick is the event by which u can handle the click events of button. Just add buttons at design time using smart tag that u know. In eventHandler give MassageBox.Show("Ok"); On Clicking button in datagridview u will see this msg.

          R 1 Reply Last reply
          0
          • D deepseeindeepsy

            CellContentClick is the event by which u can handle the click events of button. Just add buttons at design time using smart tag that u know. In eventHandler give MassageBox.Show("Ok"); On Clicking button in datagridview u will see this msg.

            R Offline
            R Offline
            Rahul DSG
            wrote on last edited by
            #5

            ok thats right...but cellcontent_click event is fired when u click the header of the datagridview...then its a problem...

            M D 2 Replies Last reply
            0
            • R Rahul DSG

              ok thats right...but cellcontent_click event is fired when u click the header of the datagridview...then its a problem...

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #6

              So inspect the event arguments (e) to determine who clicked it.

              Never underestimate the power of human stupidity RAH

              1 Reply Last reply
              0
              • R Rahul DSG

                ok thats right...but cellcontent_click event is fired when u click the header of the datagridview...then its a problem...

                D Offline
                D Offline
                deepseeindeepsy
                wrote on last edited by
                #7

                No. Its not. You will get the event on clicking control that u have added(like as checkbox,button,combobox etc.). Just cross check... It works properly. :)

                1 Reply Last reply
                0
                • R Rahul DSG

                  i am working in a window Application and using a Gridview.In this gridview i am adding a button but can't find Button_Click Event... Plz Dont tell me about Cell_click Event.Its Not working Properly... Need A Help.. Thanks

                  H Offline
                  H Offline
                  Henry Minute
                  wrote on last edited by
                  #8

                  Please take a look at this reply to a similar question in the VB forum. RE-How-can-i-get-this-checkbox-to-work-when-it-is-selected.aspx[^] As it is in the VB forum it is in VB.Net but you should be able to follow well enough to convert it into C# Hope this helps. :)

                  Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                  1 Reply Last reply
                  0
                  • R Rahul DSG

                    i am working in a window Application and using a Gridview.In this gridview i am adding a button but can't find Button_Click Event... Plz Dont tell me about Cell_click Event.Its Not working Properly... Need A Help.. Thanks

                    K Offline
                    K Offline
                    Kaushal Arora
                    wrote on last edited by
                    #9

                    Use the "CommandName" property of the Button and set it to What ever name you want to give and the "CommandArgument" property to the unique id of that row to get the same. You can catch the same in the RowCommand Event of the Gridview as

                    if (e.CommandName == "WhatEverYouNamed")
                    {
                    // Your Set of Commands and you can get the Unique Key value using e.CommandArgument.
                    }

                    Using this you can have multiple buttons doing multiple things in one gridview. Regards, Kaushal Arora Please Mark as Answer if it solved your problem.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups