Results 1 to 4 of 4

Thread: Masking a Binding DataGrid control

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    27

    Masking a Binding DataGrid control

    [code]

    Dim bndTemp As Binding

    bndTemp = New Binding("Text", DsCustomersDB1, "tblCustomers.fldCustPFCDate")

    txtCustPFC.DataBindings.Add(bndTemp)

    [code]


    The result of the above code has variable fldCustPFCDate with the value of: 9/1/2005 12:00:00 AM

    In my Access tblCustomers data table, fldCustPFCDate has a format of short date and only contains the date: 9/1/2005 as its value.

    My question is how do I mask this New Binding statement to show only the date?

    Thanks,
    Soleman

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: Masking a Binding DataGrid control

    Maybe like this:
    VB Code:
    1. Dim bndTemp As Binding
    2. bndTemp = New Binding("Text", DsCustomersDB1, ctype("tblCustomers.fldCustPFCDate",date).ToShortDateString)
    3.                    
    4. txtCustPFC.DataBindings.Add(bndTemp)

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    27

    Re: Masking a Binding DataGrid control

    Hi Wild Bill!

    I tried your suggestion and a get the following error:

    Cast from string "tblCustomers.fldCustPFCDate" to type 'Date' is not valid

  4. #4
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: Masking a Binding DataGrid control

    VB Code:
    1. For Each dr As DataRow In DsCustomersDB1.Tables("tblCustomers").Rows
    2.             dr.Item("fldCustPFCDate") = CType(dr.Item("fldCustPFCDate"), Date).ToShortDateString
    3.         Next
    4.         Dim bndTemp As Binding = New Binding("Text", DsCustomersDB1.Tables("tblCustomers"), "fldCustPFCDate")
    5.         txtCustPFC.DataBindings.Add(bndTemp)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width