You are on page 1of 2

http://www.megaupload.com/?

d=7ERT3UOC
http://www.megaupload.com/?d=NIT3H6OR
http://www.megaupload.com/?d=7HL1GODL

2011 :
http://madness-madman.hooxs.com/register

> Comment peut-on aller d'une ligne l'autre dans un datagridview, sans
> utiliser la souris ?
> La proprit CurrentRow n'est qu'en lecture seule. Je ne peux donc pas
> crire :
> -------------------------------------------------------
> Me.DataGridViewRow.CurrentRow=ThisRow
> -------------------------------------------------------
> C'est pourtant ce que je voudrais simuler.
>
> A dfaut d'une mthode rapide, j'ai crit :
> -------------------------------------------------------
> Sub GotoFilm (id_film)
> For Each row As DataGridViewRow In DataGridView1.Rows
> If CType(row.Cells("id_film").Value, Integer) = id_film Then
> DataGridView1.FirstDisplayedScrollingRowIndex = row.Index
> DataGridView1.Rows(row.Index).Selected = True
> DataGridView1.Select()
> Exit For
> End If
> Next
> End Sub
> -------------------------------------------------------
> Je suis sr qu'il y a plus rapide et plus lgant. D'autre part en me
> posant ainsi sur la range, l'vnement RowEnter ne se produit pas.
>
> Merci de bien vouloir me rpondre.
>

( ), ...
Split, ,
, DataGridView1 Button1
Button1 .
Button2 .
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal Sender As System.Object, ByVal E As System.EventArg
s) Handles MyBase.Load
DataGridView1.Columns.Add("CName", "Name")
DataGridView1.Columns.Add("CMiddleN", "Middle Name")
DataGridView1.Columns.Add("CLastN", "Last Name")
DataGridView1.Columns.Add("CPhoneN", "Phone Number #")
DataGridView1.Columns.Add("CE-mail", "E-mail Address")
For I As Integer = 0 To 19
Dim NRow As String() = {"Empty", "Empty", "Empty", Rnd() * I, "Empty@Hotmail.com
"}
DataGridView1.Rows.Add(NRow)
Next
End Sub
Private Sub Button1_Click(ByVal Sender As System.Object, ByVal E As System.Event
Args) Handles Button1.Click
Dim OP As New OpenFileDialog
If OP.ShowDialog = 1 Then
Dim Lines() As String = File.ReadAllLines(OP.FileName)
For Each Line As String In Lines
DataGridView1.Rows.Add(Line.Split(","))
Next
End If
End Sub
Private Sub Button2_Click(ByVal Sender As System.Object, ByVal E As System.Event
Args) Handles Button2.Click
Dim SV As New SaveFileDialog
If SV.ShowDialog = 1 Then
Dim St As New StreamWriter(SV.FileName, FileMode.OpenOrCreate)
For Each DGVR As DataGridViewRow In DataGridView1.Rows
If Not DGVR.Cells(0).Value = String.Empty Then
Dim Line As String = String.Empty
For I As Integer = 0 To 3
Line &= DGVR.Cells(I).Value & ","
Next
Line &= DGVR.Cells(4).Value
St.WriteLine(Line)
End If
Next
St.Close()
End If
End Sub
End Class

You might also like