Region of Cell within DataGridView

q1w2e3r4t7

Freshman
Joined
Nov 15, 2005
Messages
30
Is it possible to get the region of cells within a datagridview control ?
i want to be able to put a combo box or another control over cells when entering data

Currently i'm using the follwoing code:

Code:
        Dim left As Int16 = DataGridView1.Left + DataGridView1.RowHeadersWidth
        Dim i As Int16
        For i = 0 To e.ColumnIndex - 1
            If DataGridView1.Columns(i).Displayed Then left += DataGridView1.Columns(i).Width
        Next

        Dim top As Int16 = DataGridView1.Top + DataGridView1.ColumnHeadersHeight
        For i = 0 To e.RowIndex - 1
            If DataGridView1.Rows(i).Displayed Then top += DataGridView1.Rows(i).Height
        Next
        Button.Top = top
        Button.Left = left

        Button.Height = DataGridView1.Item(e.ColumnIndex, e.RowIndex).OwningRow.Height
        ButtButtonon5.Width = DataGridView1.Item(e.ColumnIndex, e.RowIndex).OwningColumn.Width

however, this when only half of a cell is displayed, the alignment is out of place.

Does anyone have a better method?

Thanks
 
Back
Top