Jump to content

Recommended Posts

Posted

Boas pessoal estou a querer mudar uma gridview para uma listview, o carregamento dos dados ja os consegui fazer bem como o resgate dos valores da linha seleccionada, a minha duvida agora é como posso colocar o tamanho das colunas automatico de acordo com o tamanho do texto contido nas celulas das colunas?

Como posso criar um for deste genero:

For row As Integer = 0 To DataGridView1.RowCount - 1
        Dim inicio As DateTime
        inicio = Today
        Dim fim As DateTime
        fim = DataGridView1.Item(3, row).Value
        Dim dif As TimeSpan = fim.Subtract(inicio)
        Dim dias As Integer = dif.Days
        If dias = 3 Then
         With Me.DataGridView1.Rows(row).DefaultCellStyle
        .BackColor = Color.SpringGreen
        End With
        ElseIf dias = 2 Then
        With Me.DataGridView1.Rows(row).DefaultCellStyle
         .BackColor = Color.Green
        End With
        ElseIf dias = 1 Then
        With Me.DataGridView1.Rows(row).DefaultCellStyle
        .BackColor = Color.OrangeRed
        End With
        ElseIf dias <= 0 Then
        With Me.DataGridView1.Rows(row).DefaultCellStyle
         .BackColor = Color.Red
        .Font = New Font("Tahona", 12, FontStyle.Bold)
        End With
        End If
        Next

Mas para listview, ou entao em vez de pintar as linhas criar uma coluna com uma certa imagem?

Outra duvida e como ocultar colunas, eu ja consegui, mas se o utilizador for reajustar as colunas elas podem aparecer....

Alguem me consegue ajudar?

Cumps

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.