SelectedCells Order

alim

Well-known member
Joined
Dec 12, 2005
Messages
89
Location
bangladesh
Programming Experience
3-5
When i selected cells in Datagridview.. you knw it will not give u the right order to work with so i tried
in coding
Every thing is right bt i m getting those value in diffrect order

I knw bcoz depend on the selection order .. can i do something to have the
index right order or i have to work with Rows.
plz guys help me....

VB.NET:
Public Sub Paste_Rows_From_Excel_Grid(ByVal G As DataGridView, ByVal CopiedTxt As String)
        Dim Ar As Array = Split(CStr(Trim(CopiedTxt)), vbCrLf)
        For K As Integer = G.SelectedCells.Count - 1 To 0 Step -1
            If Ar.Length - 1 >= K Then
                If SoftIn.Get_DataType_NumberGrid(G, G.SelectedCells(K).ColumnIndex) = True Then'it will give me the datatype is 'num or not

                    G.SelectedCells(K).Value = Val(Ar(K))
                ElseIf WGeT.ToLower = "datetime" Then     'wget will catch every datatype
                    If IsDate(Ar(K)) = True Then G.SelectedCells(K).Value = Dat2(Ar(K))
                ElseIf WGeT.ToLower = "string" Then
                    G.SelectedCells(K).Value = ArV2(Ar, K)'its my function give me the array value
                End If
            End If
        Next

    End Sub
 
Last edited:
let me make this simple...

such as i have selected some cell in one column from upper to down

so i have to input "a"+OrderIndex value in every selectedCells...

VB.NET:
For k as integer = 0 to me.Gview.SelectedCells.count-1
gview.selectedcells(k).value ="a" + K

next

you will not have the same order index every time even though you are selecting same cells but in different orders...

But we get same value in excel .. i want to get values like excel copy paste...

please help me as soon as possible....
 
Back
Top