0

I have a gridview which is filled by a query. I want to allow the user to highlight and copy text from the cell, which is double clicked. here is my event code:

Private Sub datagridview2_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles datagridview2.CellDoubleClick
    datagridview2.SelectionMode = DataGridViewSelectionMode.CellSelect

    datagridview2.CurrentCell.Selected = True
    datagridview2.ReadOnly = False
    datagridview2.BeginEdit(False)


End Sub

This works fine with the exception that the user is allowed to change text. I just want to let him highlight the text and copy and paste it. I guess it is an easy edit control but i dont know it yet. Can somebody help out?

Edit: I removed the word paste because it sound confusing. Here is an example: cell value: "5 dublettes found: 11111, 22222,33333,44444,5555" I want to make it possible to only highlight 33333 and copy it via strg+c. With the premise, that the cell value is not changable.

Friendly greetings

b101

steve
  • 123
  • 1
  • 14
  • if you allow them to paste text it is changing text. your question contradictory – Ňɏssa Pøngjǣrdenlarp May 05 '14 at 13:53
  • well yes, my text is contradictory to understand. I mean copy it from the grid and then paste it into excel.. – steve May 05 '14 at 14:21
  • one alternative option might be to dd a context menu to the cell with a menu item to copy the text – Phillip Trelford May 05 '14 at 17:32
  • Your suggestion sounds good but I still have the problem that not a spicific part of the cell can be copied. And in my Programm its possible to select a single cell, which can be copied with strg + c – steve May 06 '14 at 06:58

1 Answers1

0

I found an answer to my question here:

Windows Forms Datagridview (Select part of text in cell with mousepointer but dont allow edit) VB.NET

it works perfektly!

Community
  • 1
  • 1
steve
  • 123
  • 1
  • 14