deleting columns which are not necessary using datetime pickers.

kodandekod

New member
Joined
Apr 26, 2012
Messages
3
Programming Experience
Beginner
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.
 
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.
 
Back
Top