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. Programatically adding checkboxes to datagridview

Programatically adding checkboxes to datagridview

Scheduled Pinned Locked Moved C#
databasehelp
7 Posts 3 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.
  • D Offline
    D Offline
    deepseeindeepsy
    wrote on last edited by
    #1

    Hi there, I want to add dynamically checkboxes to the datagridview rows which displays data on textchange event of a textbox using LIKE query. On clicking checkboxes I want to go for further coding. Please help.

    S M 2 Replies Last reply
    0
    • D deepseeindeepsy

      Hi there, I want to add dynamically checkboxes to the datagridview rows which displays data on textchange event of a textbox using LIKE query. On clicking checkboxes I want to go for further coding. Please help.

      S Offline
      S Offline
      saanj
      wrote on last edited by
      #2

      The same question was asked few threads earlier: http://www.codeproject.com/Messages/3071608/Dynamically-adding-checkboxes-in-datagridview.aspx[^] Regards Saanj

      Either you love IT or leave IT...

      D 1 Reply Last reply
      0
      • S saanj

        The same question was asked few threads earlier: http://www.codeproject.com/Messages/3071608/Dynamically-adding-checkboxes-in-datagridview.aspx[^] Regards Saanj

        Either you love IT or leave IT...

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

        Hi, That question was raised by me itself but, I couldn't find right answer. One who suggested me at design time instead of runtime. Please help. :)

        S 1 Reply Last reply
        0
        • D deepseeindeepsy

          Hi, That question was raised by me itself but, I couldn't find right answer. One who suggested me at design time instead of runtime. Please help. :)

          S Offline
          S Offline
          saanj
          wrote on last edited by
          #4

          Does the textbox reside inside the grid view or some where else? Are you trying to say that on the textchanged event of the textbox, checkbox lists should be created with the data that depends upon the textbox's text right. You can add a Template Column in the gridview. Drag a checkbox list in the ItemTemplate. Set the autpostback to true ande define an event. This event will be common for all checkboxes in your gridview. Now in the RowDataBound event of your gridview, just set the items of the checkbox list depending upon the data that you want to bind. As you have already set the event with the checkbox list, you can do what ever you want in the checkboxlist selected index changed event. It's a bit long discussion but I hope something is clear now If I took your words right. :) Regards Saanj

          Either you love IT or leave IT...

          D 1 Reply Last reply
          0
          • D deepseeindeepsy

            Hi there, I want to add dynamically checkboxes to the datagridview rows which displays data on textchange event of a textbox using LIKE query. On clicking checkboxes I want to go for further coding. Please help.

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

            You can add a COLUMN of checkboxes, you cannot add a chackbox to a single row. I use the following:

            DataGridViewCheckBoxColumn oDGC = new DataGridViewCheckBoxColumn();
            oDGC.HeaderText = "Sel";
            oDGC.Name = "Sel";
            oDGC.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
            oDGC.FlatStyle = FlatStyle.Standard;
            oDGC.CellTemplate = new DataGridViewCheckBoxCell();
            oDGC.CellTemplate.Style.BackColor = System.Drawing.Color.Beige;
            oDGC.ThreeState = false;
            oDG.Columns.Insert(iCol, oDGC);

            Never underestimate the power of human stupidity RAH

            1 Reply Last reply
            0
            • S saanj

              Does the textbox reside inside the grid view or some where else? Are you trying to say that on the textchanged event of the textbox, checkbox lists should be created with the data that depends upon the textbox's text right. You can add a Template Column in the gridview. Drag a checkbox list in the ItemTemplate. Set the autpostback to true ande define an event. This event will be common for all checkboxes in your gridview. Now in the RowDataBound event of your gridview, just set the items of the checkbox list depending upon the data that you want to bind. As you have already set the event with the checkbox list, you can do what ever you want in the checkboxlist selected index changed event. It's a bit long discussion but I hope something is clear now If I took your words right. :) Regards Saanj

              Either you love IT or leave IT...

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

              Sir, Your first statement was right that I m having textbox outside to that of datagridview. You gave the code which was in ASP.NET but,I m working on C# Windows. Even I succeeded in adding checkboxes at runtime on textchange event of external checkbox on your behalf....Thanks. But, now I m quering about how will I get the appropriated row record on clicking respective checkbox on the row ? Is there any event about databinding events to succeed further? I want to check it for furher process. Please help. awaiting................. :-O

              S 1 Reply Last reply
              0
              • D deepseeindeepsy

                Sir, Your first statement was right that I m having textbox outside to that of datagridview. You gave the code which was in ASP.NET but,I m working on C# Windows. Even I succeeded in adding checkboxes at runtime on textchange event of external checkbox on your behalf....Thanks. But, now I m quering about how will I get the appropriated row record on clicking respective checkbox on the row ? Is there any event about databinding events to succeed further? I want to check it for furher process. Please help. awaiting................. :-O

                S Offline
                S Offline
                saanj
                wrote on last edited by
                #7

                Hi, I am sorry but I have very limited experience on Win Forms. But I can refer the following link: [^][^] Regards Saanj

                Either you love IT or leave IT...

                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