I will start by explaining what I am trying to achieve.
I have a DataGridView in Visual Studio and when I click on a cell, that cell is converted to a button. Reason for this is I want the grid to look like a project planner. So I want people to select a number of cells (on the same line) and on MouseUp the cells must get converted to one button.
I managed to convert only 1 cell at a time to a button but when I select many cells it simply doesn't let me do it. (and I am not sure how to achieve this)
As you can see from the image below, when I click on individual cells they get converted to button but ultimately I want to select a number of cells and on MouseUp it should convert them to a button.
http://postimage.org/image/o0kkgsnpp/
Reason I chose a button is because in future I will add drag and drop functionality so that I am able to drag that button to a new line for example. It doesn't mean I can't do this another way if it is more efficient so any recommendation will be welcome.
This is the code I am using to convert to button so please have a look at it and let me know how I can achieve this functionality:
Blockquote
. . . AddHandler Grid.CellMouseUp, AddressOf Grid_MouseUp
End Sub
Private Sub Grid_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs)
Dim ButtonColumn As New DataGridViewButtonCell
For Each cell As DataGridViewCell In Grid.SelectedCells
Grid(cell.ColumnIndex, cell.RowIndex) = ButtonColumn
Next cell
End Sub
Blockquote