Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how can i set default value of checkbox in datagrid = False, the default value is "", it is greyed out and checked

Posted on 2004-08-24
9
Medium Priority
?
390 Views
Last Modified: 2012-05-05
hi, this is how i add a checkbox column to the datagrid, in the datatablestyle

            Dim CheckBox1 As DataGridBoolColumn
            CheckBox1 = New DataGridBoolColumn
            CheckBox1.MappingName = "Checkbox1"
            CheckBox1.ReadOnly = False
            CheckBox1.Width = 1
            tsJob.GridColumnStyles.Add(CheckBox1)

and now the grid is displayed, but all the checkboxes are type of greyed out, but checked, but the value is "" , as opposed to true or false, how can i have the default value in the checkbox = False?
the syncfusion sets the default row by row.
e.g.
tCust.Rows[0]["Current'] = true;
i use a dataview to set the databinding for the datagrid
i can supply a demo piece of code if needed
thanks!
0
Comment
Question by:jxharding
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 18

Assisted Solution

by:DotNetLover_Baan
DotNetLover_Baan earned 400 total points
ID: 11881451
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11881463
have you tried this

        CheckBox1.NullValue = False
0
 

Author Comment

by:jxharding
ID: 11881620
hi, i tried the checkbox1.nullvalue = false, but i still got the greyed out box, although the statement makes sense.

and i  tried this from the second link:
 myGridColumn.TrueValue = true
 myGridColumn.FalseValue = false
 myGridColumn.NullValue = Convert.DBNull

but still i get the value  = ""

 i even tried:
CheckBox1.NullText = "False"
but nada.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11881813
Before using Null values , try seting AllowNull property to true.
myGridColumn.AllowNull = True
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11882058
this seems to work

        CheckBox1.NullValue = Convert.DBNull
        CheckBox1.FalseValue = Convert.DBNull
        CheckBox1.TrueValue = True

ofcourse

unchecking will make your boolean value in the database dbnull
0
 

Author Comment

by:jxharding
ID: 11882073
hi, i just tried it, but no go, i typed out a simulation of the problem.
if you could please copy and paste it into a form.
the real dataset is strongly typed, but i kept this one normally typed for copy and pasting .
thanks!


Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim ds As New DataSet
#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.DataGrid1 = New System.Windows.Forms.DataGrid
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'DataGrid1
        '
        Me.DataGrid1.DataMember = ""
        Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.DataGrid1.Location = New System.Drawing.Point(32, 32)
        Me.DataGrid1.Name = "DataGrid1"
        Me.DataGrid1.Size = New System.Drawing.Size(296, 208)
        Me.DataGrid1.TabIndex = 0
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(368, 273)
        Me.Controls.Add(Me.DataGrid1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ds1 As New DataSet("ds")
        Dim dt As New DataTable("Test")
        Dim c1 As New DataColumn("Checked1")
        c1.DataType = System.Type.GetType("System.Boolean")
        dt.Columns.Add(c1)

        ds1.Tables.Add(dt)
        Dim i As Integer

        For i = 0 To 2
            Dim Newrow1 As DataRow
            Newrow1 = dt.NewRow
            ''''''''''Newrow1("Checked1") = False       'this is just a sample, i cannot
            'add this section to the real project
            dt.Rows.Add(Newrow1)
        Next

        Dim dv As New DataView(ds1.Tables("Test"))
        dv = ds1.Tables(0).DefaultView
        DataGrid1.DataSource = dv

        Dim dstyle1 As New DataGridTableStyle
        Dim CheckBox1 As DataGridBoolColumn
        CheckBox1 = New DataGridBoolColumn
        CheckBox1.MappingName = "Checked1"
        CheckBox1.Width = 50

        'ATTEMPTS
        CheckBox1.AllowNull = True
        CheckBox1.TrueValue = True
        CheckBox1.FalseValue = False
        CheckBox1.NullValue = Convert.DBNull

        dstyle1.GridColumnStyles.Add(CheckBox1)
        DataGrid1.TableStyles.Add(dstyle1)
    End Sub
End Class
0
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 1600 total points
ID: 11882138
this seems to work

        CheckBox1.NullValue = Convert.DBNull
        CheckBox1.FalseValue = Convert.DBNull
        CheckBox1.TrueValue = True

ofcourse

unchecking will make your boolean value in the database dbnull

0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11882144
Oeps, pressed submit again
0
 

Author Comment

by:jxharding
ID: 11882274
excellent, thank you both very much!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question