Chamuanza Posted March 17, 2015 at 02:49 PM Report Share #579619 Posted March 17, 2015 at 02:49 PM 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 More sharing options...
jpcarvalho1992 Posted March 17, 2015 at 02:53 PM Report Share #579620 Posted March 17, 2015 at 02:53 PM Boas se poderes anexa também o text file. 😉 Link to comment Share on other sites More sharing options...
Chamuanza Posted March 17, 2015 at 03:18 PM Author Report Share #579624 Posted March 17, 2015 at 03:18 PM 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 Link to comment Share on other sites More sharing options...
Solution jpcarvalho1992 Posted March 18, 2015 at 03:46 PM Solution Report Share #579730 Posted March 18, 2015 at 03:46 PM Assim já te posso ajudar 😉 Podes verificar inicialmente que ele somente está a formatar utilizando o primeiro dígito, faz a leitura do teu código e podes verificar que é isso exactamente que o fazes. Se tiveres com dificuldade diz. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now