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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Problem in bring a checkbox inside a datagrid in windows application..

Problem in bring a checkbox inside a datagrid in windows application..

Scheduled Pinned Locked Moved Visual Basic
help
8 Posts 2 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.
  • B Offline
    B Offline
    Balagurunathan S
    wrote on last edited by
    #1

    Hi friends.. I need to bind a checkbox to the first column of my datagrid..I use the following code to do so...I bind the datagrid through a dataset named "ldst" .The code is below ldst = lobjclass1.TIC_GET_tTic_MM_ServiceType(0) now i am getting the dataset with values in it..After this i am using the following code to bind checkbox within the datagrid(datagrid1).. Dim tableStyle As New DataGridTableStyle tableStyle.MappingName = "ldst" Dim discontinuedCol As New DataGridBoolColumn discontinuedCol.MappingName = "Discontinued" discontinuedCol.HeaderText = "" discontinuedCol.Width = 30 'turn off tristate discontinuedCol.AllowNull = False tableStyle.GridColumnStyles.Add(discontinuedCol) 'Step 2: AgentID Dim column As New DataGridTextBoxColumn column.MappingName = "AgentID" column.HeaderText = "AgentID" column.Width = 30 tableStyle.GridColumnStyles.Add(column) 'Step 2: Bank Name column = New DataGridTextBoxColumn column.MappingName = "Bank Name" column.HeaderText = "Bank Name" column.Width = 140 tableStyle.GridColumnStyles.Add(column) 'Step 2: Branch Name column = New DataGridTextBoxColumn column.MappingName = "Branch Name" column.HeaderText = "Branch Name" tableStyle.GridColumnStyles.Add(column) 'Step 2: City column = New DataGridTextBoxColumn column.MappingName = "City" column.HeaderText = "City" tableStyle.GridColumnStyles.Add(column) 'Step 2: Cheque / DD Date column = New DataGridTextBoxColumn column.MappingName = "Cheque / DD Date" column.HeaderText = "Cheque / DD Date" tableStyle.GridColumnStyles.Add(column) 'Step 2: Cheque / DD No column = New DataGridTextBoxColumn column.MappingName = "Cheque / DD No" column.HeaderText = "Cheque / DD No" tableStyle.GridColumnStyles.Add(column) 'Step 2: Pay Type column = New DataGridTextBoxColumn column.MappingName = "Pay Type" column.HeaderText = "Pay Type" tableStyle.GridColumnStyles.Add(column) 'Step 3: Add the tablestyle to th

    D 1 Reply Last reply
    0
    • B Balagurunathan S

      Hi friends.. I need to bind a checkbox to the first column of my datagrid..I use the following code to do so...I bind the datagrid through a dataset named "ldst" .The code is below ldst = lobjclass1.TIC_GET_tTic_MM_ServiceType(0) now i am getting the dataset with values in it..After this i am using the following code to bind checkbox within the datagrid(datagrid1).. Dim tableStyle As New DataGridTableStyle tableStyle.MappingName = "ldst" Dim discontinuedCol As New DataGridBoolColumn discontinuedCol.MappingName = "Discontinued" discontinuedCol.HeaderText = "" discontinuedCol.Width = 30 'turn off tristate discontinuedCol.AllowNull = False tableStyle.GridColumnStyles.Add(discontinuedCol) 'Step 2: AgentID Dim column As New DataGridTextBoxColumn column.MappingName = "AgentID" column.HeaderText = "AgentID" column.Width = 30 tableStyle.GridColumnStyles.Add(column) 'Step 2: Bank Name column = New DataGridTextBoxColumn column.MappingName = "Bank Name" column.HeaderText = "Bank Name" column.Width = 140 tableStyle.GridColumnStyles.Add(column) 'Step 2: Branch Name column = New DataGridTextBoxColumn column.MappingName = "Branch Name" column.HeaderText = "Branch Name" tableStyle.GridColumnStyles.Add(column) 'Step 2: City column = New DataGridTextBoxColumn column.MappingName = "City" column.HeaderText = "City" tableStyle.GridColumnStyles.Add(column) 'Step 2: Cheque / DD Date column = New DataGridTextBoxColumn column.MappingName = "Cheque / DD Date" column.HeaderText = "Cheque / DD Date" tableStyle.GridColumnStyles.Add(column) 'Step 2: Cheque / DD No column = New DataGridTextBoxColumn column.MappingName = "Cheque / DD No" column.HeaderText = "Cheque / DD No" tableStyle.GridColumnStyles.Add(column) 'Step 2: Pay Type column = New DataGridTextBoxColumn column.MappingName = "Pay Type" column.HeaderText = "Pay Type" tableStyle.GridColumnStyles.Add(column) 'Step 3: Add the tablestyle to th

      D Offline
      D Offline
      darkelv
      wrote on last edited by
      #2

      Does your ldst.tables(0) has a boolean column inside it? You set the datagrid's DataSource = ldst.tables(0).

      B 1 Reply Last reply
      0
      • D darkelv

        Does your ldst.tables(0) has a boolean column inside it? You set the datagrid's DataSource = ldst.tables(0).

        B Offline
        B Offline
        Balagurunathan S
        wrote on last edited by
        #3

        No.. I dont have any boolean column inside it..Moreover in the below code the table name has to be given in this tablestyle.MappingName.But since i have got the dataset being filled by a stored procedure..i couldn't do that..So what i should i specify in this tablestyle.MappingName..At present i have just given the dataset name in it i.e ldst which is not working.. tableStyle.MappingName = "ldst" Moreover if i use datagrid1.datasource= ldst.tables(0)..I get the values but without the checkbox column which is of no need.. Kindly reply...

        Balaguru

        D 1 Reply Last reply
        0
        • B Balagurunathan S

          No.. I dont have any boolean column inside it..Moreover in the below code the table name has to be given in this tablestyle.MappingName.But since i have got the dataset being filled by a stored procedure..i couldn't do that..So what i should i specify in this tablestyle.MappingName..At present i have just given the dataset name in it i.e ldst which is not working.. tableStyle.MappingName = "ldst" Moreover if i use datagrid1.datasource= ldst.tables(0)..I get the values but without the checkbox column which is of no need.. Kindly reply...

          Balaguru

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

          Try to see whether you can add the bool column in the dataset.table after you got it from the SP. Be careful if you're going to save the dataset back to DB though, but since you got the dataset from a stored procedure I guess it's safe.

          B 1 Reply Last reply
          0
          • D darkelv

            Try to see whether you can add the bool column in the dataset.table after you got it from the SP. Be careful if you're going to save the dataset back to DB though, but since you got the dataset from a stored procedure I guess it's safe.

            B Offline
            B Offline
            Balagurunathan S
            wrote on last edited by
            #5

            Dear Darkelv.. I am just displaying a checkbox in that datagrid's first column..I am not going to affect that table by any means with that checkbox..Ideally the checkbox itself is not shown..Then how could i think of making some changes in that table by means of that checkbox..? Reply in this regard... Thanks & Regards,

            Balaguru

            D 1 Reply Last reply
            0
            • B Balagurunathan S

              Dear Darkelv.. I am just displaying a checkbox in that datagrid's first column..I am not going to affect that table by any means with that checkbox..Ideally the checkbox itself is not shown..Then how could i think of making some changes in that table by means of that checkbox..? Reply in this regard... Thanks & Regards,

              Balaguru

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

              Well what I mean was just be careful that if you going to save the dataset back to DB, the extra column will probably cause problem. As you are not going to save the dataset back to DB, I think it should be fine.

              B 1 Reply Last reply
              0
              • D darkelv

                Well what I mean was just be careful that if you going to save the dataset back to DB, the extra column will probably cause problem. As you are not going to save the dataset back to DB, I think it should be fine.

                B Offline
                B Offline
                Balagurunathan S
                wrote on last edited by
                #7

                Ok then..Wats the solution to bring that checkbox into that datagrid..? Regards,

                Balaguru

                D 1 Reply Last reply
                0
                • B Balagurunathan S

                  Ok then..Wats the solution to bring that checkbox into that datagrid..? Regards,

                  Balaguru

                  D Offline
                  D Offline
                  darkelv
                  wrote on last edited by
                  #8

                  Well, since I do not know your system environment and what do you intend to do with the grid. 1. Have the column be added in the DataTable, by adding directly to Columns after you have gotten the result (I am not sure if you are able to add, kinda rusty with dataset). 2. Have the column be added in the DataTable, by using a Function to call the SP, then do a "Select [new bool column], * from Function(params)". I think you should be able to do that. 3. Transfer the data from DataTable to a collection of struct/class that has the additional bool property, and bind to the collection. May not fit your system design. 4. Beg the db owner? ;)

                  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