Check Box in the Datagrid

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

    #1

    Check Box in the Datagrid

    I need to add editable check box column to the data grid. I have field in the
    SQL table with the type tinyint, which is translated to the unsigned bite in
    the datatable.
    I added DataGridBoolCol umn to the table style with AllowNull = False,
    TrueValue = 1 and FalseValue = 0. Everything looks fine but when I run the
    form all checkboxes appear checked and not connected to underlying field. Any
    suggestions?
    Thanks Bronislav.
  • Cor Ligthert

    #2
    Re: Check Box in the Datagrid

    Bronislav,

    Here a very simple sample about the use of styles with the textbox and
    boolcolumn



    I hope this helps,

    Cor


    Comment

    • Bronislav

      #3
      Re: Check Box in the Datagrid

      I'm using GUI to build the form.
      It built the code:

      'DtGrdTblStlVol canos
      '
      Me.DtGrdTblStlV olcanos.DataGri d = Me.grdVolcanos
      Me.DtGrdTblStlV olcanos.GridCol umnStyles.AddRa nge(New
      System.Windows. Forms.DataGridC olumnStyle() {Me.DtGrdColVol canoName,
      Me.DtGrdColVolc anoLocation, Me.DtGrdColVolc anoLongitude,
      Me.DtGrdColVolc anoLatitude, Me.DtGrdColWebM etVolcanoStatus })
      Me.DtGrdTblStlV olcanos.HeaderF ont = New
      System.Drawing. Font("Microsoft Sans Serif", 8.25!,
      CType((System.D rawing.FontStyl e.Bold Or System.Drawing. FontStyle.Under line),
      System.Drawing. FontStyle), System.Drawing. GraphicsUnit.Po int, CType(0, Byte))
      Me.DtGrdTblStlV olcanos.HeaderF oreColor =
      System.Drawing. SystemColors.De sktop
      Me.DtGrdTblStlV olcanos.Mapping Name = "WebMetVolc ano"

      'DtGrdColWebMet VolcanoStatus
      '
      Me.DtGrdColWebM etVolcanoStatus .AllowNull = False
      Me.DtGrdColWebM etVolcanoStatus .FalseValue = 0
      Me.DtGrdColWebM etVolcanoStatus .HeaderText = "Active"
      Me.DtGrdColWebM etVolcanoStatus .MappingName = "WebMetVolcanoS tatus"
      Me.DtGrdColWebM etVolcanoStatus .NullValue =
      CType(resources .GetObject("DtG rdColWebMetVolc anoStatus.NullV alue"), Object)
      Me.DtGrdColWebM etVolcanoStatus .TrueValue = 1
      Me.DtGrdColWebM etVolcanoStatus .Width = 75

      It looks OK for me but doesn't work. If I change the column style of the
      column to standart text box it will show proper value from the data table.
      Thanks Bronislav.



      "Cor Ligthert" wrote:
      [color=blue]
      > Bronislav,
      >
      > Here a very simple sample about the use of styles with the textbox and
      > boolcolumn
      >
      > http://www.windowsformsdatagridhelp....6-3300b2215049
      >
      > I hope this helps,
      >
      > Cor
      >
      >
      >[/color]

      Comment

      • Cor Ligthert

        #4
        Re: Check Box in the Datagrid

        Bronislav,

        The styles are for a windowform datagrid. I get the idea that you want to
        use it for a webform datagrid. That are almost completly different controls,
        with the exception that they should do the same.

        Cor


        Comment

        Working...