Results 1 to 2 of 2

Thread: deleting columns which are not necessary using datetime pickers.

  1. #1
    kodandekod is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Apr 2012
    Posts
    3
    Reputation
    0

    deleting columns which are not necessary using datetime pickers.

    Hello,
    I have a datagridview with column names as dates.
    e.g.

    Name 1/1/2001 2/1/2001 3/1/2001 4/1/2001 5/1/2001

    name1 2krona 4krona 7krona 8krona 21krona

    name2 12krona 32krona 66krona 44krona 333krona

    name3 1krona 23krona 3 krona 99krona 2krona

    i adding 2 datepickers one for from date and the other for to date.

    when click the from date as 2/1/2001 and to date as 4/1/2001. i need the result as


    Name 2/1/2001 3/1/2001 4/1/2001
    name1 4krona 7krona 8krona

    name2 32krona 66krona 44krona

    name3 23krona 3 krona 99krona

    it must work 4 many values.

  2. #2
    ss7thirty is offline VB.NET Forum Miyagee
    .NET Framework
    .NET 2.0
    Join Date
    Jun 2005
    Location
    New Jersey, US
    Posts
    455
    Reputation
    174
    Each column has a name property and you could convert that column to a date and based on that value hide or leave that column.


    Dim dc As DataGridViewColumn
    For Each dc In DataGridView1.Columns
    Dim dtVal As Date = CDate(dc.Name)
    If dtVal < pickedDate Then
    dc.Visible = False
    End If
    Next


    Also just make sure you skip the columns that cannot be converted to date values because an exception will occur there.

Bookmarks

Posting Permissions

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