Jump to content
Fórum Script Brasil
  • 0

Copiar datagrid para area de transferencia


cwarez

Question

Pessoal

Tenho um data grid chamado OSGrid

preciso pegar cada celula dela e adicionar ' %, ' no final de cada celular e salvar para a area de transferencia

Exemplo:

OSGrid

20000 5858 548454

10000 2458 545454

40000 5858 548454

76000 2458 545454

Dai clicar no botao copiar e ir para o clipboard assim:

20000%, 2458%

Fix o seguinte codigo e não tive sucesso

Dim QtdRows As Integer = OSGrid.SelectedCells.Count
        Dim OsCopy(QtdRows) As String
        Dim Copiados As String = Nothing
        Dim i As Integer = 0

        'vamos obter as células selecionadas no DataGridView
        Dim selecionadas As DataGridViewSelectedCellCollection
        selecionadas = OSGrid.SelectedCells

        'vamos percorrer as células selecionadas
        
        While i < selecionadas.Count
            Dim celula As DataGridViewCell = selecionadas(i)
            Dim linha As Integer = celula.RowIndex
            Dim coluna As Integer = celula.ColumnIndex

            'armazena as celulas selecionadas no array OsCopy
            If celula.Value <> Nothing Then
                OsCopy(i) = OSGrid.Rows(linha).Cells(coluna).Value
                Copiados = Copiados & OsCopy(i) & "%,"
            End If
            i = i + 1
        End While

        'retira a ultima virgula e
        'copia para Area de Transferencia
        Clipboard.Clear()
        Clipboard.SetText(Mid(Copiados, 1, Len(Copiados) - 1))

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...