child datagridview values shd be uniq for column wise

Posted by Oswaldlily under Windows Forms on 3/25/2014 | Points: 10 | Views : 699 | Status : [Member] | Replies : 0
I have datagridview and button in windowapplication.On clicking of cell in column1 display a child datagridview for column1...when clicking cell in column2 should display a child datagridview for column2..

values in child datagridview1 and values in child datagridview 2 should be unique..should not be similar...

how to do this???

Private Sub DgV_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DgV.CellClick

If e.RowIndex <> -1 Then
If e.ColumnIndex <> -1 Then



Dim _pointCell As Point = Me.DgV.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, True).Location
Dim _pointGrid As Point = DgV.Location
Dim _pointLocation As Point
_pointLocation.X = _pointCell.X 'width
_pointLocation.Y = _pointCell.Y + 20 'height
DataGridViewColumnSelector(e.ColumnIndex)
mPopup.Show(DgV.PointToScreen(New Point(_pointLocation.X, _pointLocation.Y)))
End If
End If
End Sub



Dim gv As DataGridView = New DataGridView()

Public Function DataGridViewColumnSelector(ByVal colindex As Integer)




If colindex = 1 Then
Dim t1 As New DataGridViewTextBoxColumn()
Dim t2 As New DataGridViewTextBoxColumn()
gv.Columns.Add(t1)
gv.Columns.Add(t2)
gv.Columns(0).HeaderText = "SNO"
gv.Columns(1).HeaderText = "Code"

gv.RowHeadersVisible = False
gv.Width = t1.Width + t2.Width
gv.ScrollBars = ScrollBars.None

Else
Dim t3 As New DataGridViewTextBoxColumn()
Dim t4 As New DataGridViewTextBoxColumn()
gv.Columns.Add(t3)
gv.Columns.Add(t4)
gv.Columns(0).HeaderText = "sno"
gv.Columns(1).HeaderText = "code"

gv.RowHeadersVisible = False
gv.Width = t3.Width + t4.Width
gv.ScrollBars = ScrollBars.None
End If

Dim mControlHost As ToolStripControlHost = New ToolStripControlHost(gv)
mControlHost.Padding = Padding.Empty
mControlHost.Margin = Padding.Empty
mControlHost.AutoSize = False

mPopup = New ToolStripDropDown()
mPopup.Padding = Padding.Empty
mPopup.Items.Add(mControlHost)

End Function




Responses

(No response found.)

Login to post response