Jump to content

Formatar Coluna Datagridview


Chamuanza
 Share

Go to solution Solved by jpcarvalho1992,

Recommended Posts

Um bem Aja a Todos

Tenho uma Datagridview em que uma das colunas é preenchida com valores de tempos de um ficheiro de texto.

Sucede que ao ORDENAR ESSA COLUNA(4) aparece o registo de tempo 10,00 antes do registo 2,00.

Nas propriedades da datagridview já formatei a coluna de varias maneiras mas não consigo acertar.

Junto o código que carrega a Datagridview - Agradecia uma ajuda

//
Private Sub frmRegistoTempos_Load(sender As Object, e As EventArgs) Handles Me.Load

 Dim fName As String = "C:\Sudoku\Tempos_de_Jogos.txt" 'Vai ler o ficheiro do tipo String

    Me.DataGridView1.Rows.Clear()
    If System.IO.File.Exists(fName) Then

	    For Each line As String In System.IO.File.ReadLines(fName)

		    Dim r As New Regex("(?<campo1>\d*),(?<campo2>.*?),(?<campo3>\d*),(?<campo4>.*)")
		    Dim matches As Object = r.Matches(line)
		    If matches.Count > 0 Then
			    Dim match As Object = matches(0)
			    If match.ToString = ",,," Then Exit For
			    Me.DataGridView1.Rows.Add(match.Groups("campo1").Value, match.Groups("campo2").Value, match.Groups("campo3").Value, match.Groups("campo4").Value)
		    Else
		    End If
	    Next
    End If
    btnAtribuirJogador.Enabled = True

   'Ordenar a Coluna de Tempos
    Me.DataGridView1.Sort(Me.DataGridView1.Columns(3), ListSortDirection.Ascending)
   End Sub
Link to comment
Share on other sites

Boas jpcarvalho1992

Penso que seja isto que te referes

5,Justino,1,0,45

8,Justino,1,0,52

2,Justino,1,0,63

3,Justino,1,0,80

1,Justino,1,1,56

10,Justino,1,2,80

6,Justino,1,3,45

12,Maria,1,4,21

9,Justino,1,4,37

7,Justino,1,4,86

4,Justino,1,8,11

11,Justino,1,9,45

13,TesteJustino,1,10,0

,,,

Boas jpcarvalho1992 obrigado desde já pela atenção

Junto imagem da tabela

C9e0Wp6.gif

Link to comment
Share on other sites

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
 Share

×
×
  • 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.