Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hi,
 
I use vb.net 2010 and have a gadagrid with a tablestyle on it.
when I write value 0 in the grid, it reffer it as null. I need it to be 0.
Here is the code to create the datagridtextboxcolumn:
   Function BuildTableStyle(ByVal tsTableStyle As DataGridTableStyle, _
    ByVal clColumn As DataGridTextBoxColumn, ByVal stMappingName As String, _
    ByVal stHeader As String, ByVal dWidth As Double, ByVal stNullText As String, _
    ByVal blnReadOnly As Boolean, ByVal stFormat As String, ByVal stFormName As String, _
    ByVal dgDataGrid As DataGrid) As DataGridTextBoxColumn
        Try
            With clColumn
                .MappingName = stMappingName
                If stDataBaseType = "ORA" Then
                    .HeaderText = DecodeHeb(clsDBORA.GetDynamicHeaders(strConnection, _
                    stFormName, stHeader, stLanguageId, dgDataGrid.Name))
                ElseIf stDataBaseType = "SQL" Then
                    .HeaderText = clsDBSQL.GetDynamicHeaders(strConnection, stFormName, _
                    stHeader, stLanguageId, dgDataGrid.Name)
                End If
                .Width = dWidth * dWidthChange
                .NullText = stNullText
                .ReadOnly = blnReadOnly
                .Format = stFormat
                If blnReadOnly = True Then
                    .TextBox.BackColor = System.Drawing.Color.White
                End If
            End With
            tsTableStyle.GridColumnStyles.Add(clColumn)
            AddHandler clColumn.TextBox.KeyUp, AddressOf HandleKeyUp
            AddHandler clColumn.TextBox.KeyDown, AddressOf HandleKeyDown
            Return clColumn
        Catch ex As Exception
            HandleExceptions(ex)
            Return clColumn
        End Try
    End Function
 
and here is the code that call this function:
   Private Sub FillQueryParameters(ByRef dsQueryParameters As DataSet)
        Try
            dgParameters.HeaderFont = New System.Drawing.Font("Arial", 15.0F, _
            System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, _
            Convert.ToByte(0))
            Dim tsParameters As New DataGridTableStyle
            stDataSetTable = dsQueryParameters.Tables.Item _
            ("rep_param").ToString
            tsParameters.MappingName = stDataSetTable
            Dim clRepParam As New DataGridTextBoxColumn
            clRepParam = BuildTableStyle(tsParameters, clRepParam, "rep_param_no", _
            "clRepParam", 0, "", True, "#0", Me.Name, dgParameters)
            Dim clScreenParam As New DataGridTextBoxColumn
            clScreenParam = BuildTableStyle(tsParameters, clScreenParam, _
            "screen_param_no", "clScreenParam", 30, "", True, "#0", Me.Name, dgParameters)
            Dim clParamName As New DataGridTextBoxColumn
            clParamName = BuildTableStyle(tsParameters, clParamName, "param_name", _
            "clParamName", 150, "", True, "", Me.Name, dgParameters)
            Dim clParamType As New DataGridTextBoxColumn
            clParamType = BuildTableStyle(tsParameters, clParamType, "param_type", _
            "clParamType", 150, "", True, "", Me.Name, dgParameters)
            Dim clParamValue As New DataGridTextBoxColumn
            clParamValue = BuildTableStyle(tsParameters, clParamValue, "param_value", _
            "clParamValue", 100, 0, False, "#0", Me.Name, dgParameters)
            Dim clParameterName As New DataGridTextBoxColumn
            clParameterName = BuildTableStyle(tsParameters, clParameterName, "parameter_name", _
            "clParameterName", 0, "", False, "", Me.Name, dgParameters)
            Me.dgParameters.TableStyles.Clear()
            Me.dgParameters.TableStyles.Add(tsParameters)
            dgParameters.SetDataBinding(dsQueryParameters, "rep_param")
            Dim cmCurrencyManager As CurrencyManager = DirectCast(Me.BindingContext _
            (dgParameters.DataSource, dgParameters.DataMember), CurrencyManager)
            DirectCast(cmCurrencyManager.List, DataView).AllowNew = False
        Catch ex As Exception
            HandleExceptions(ex)
        End Try
    End Sub
 
Can anyone help please?
Thank you
Posted 22-Sep-12 6:04am
ohadw285
Edited 22-Sep-12 10:31am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Looks like OP resolved it by himself. Posting this just to pop it out of unanswered list.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 800
1 OriginalGriff 503
2 Abhinav S 253
3 thatraja 245
4 Emre Ataseven 200
0 Sergey Alexandrovich Kryukov 8,282
1 OriginalGriff 4,750
2 Peter Leow 3,784
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 22 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid