简体   繁体   中英

How to display DataGridView outside the parent control like GroupBox

获取附件快照

How can I display DataGridView outside the parent control (eg. GroupBox ) like DropDownList .

I want to display DataGridView with full of size and its content whenever I double click the Textbox but DataGridView is partially showing and hides outside the GroupBox (its parent control).

Please refer to the attached snapshot.

ClearText = New DefaultClass
ClearText.ClearTextBox(Me)

Try
    con = New SqlConnection(ConnStrSql)
    con.Open()
    da = New SqlDataAdapter("SELECT [CODE] as [Member CODE],[NAME] as [Name],[FNAME]as [Father's Name] FROM [MsumCOOP].[dbo].[MEMBER] ORDER BY [CODE] asc,[NAME] asc,[FNAME] asc", con)
    dt = New DataTable
    da.Fill(dt)
    dgvMemberCode.DataSource = dt
    If dt.Rows.Count > 0 Then
        dgvMemberCode.Location = New Point(txtMemberCode.Left, txtMemberCode.Bottom)
        dgvMemberCode.Visible = True
    Else : dgvMemberCode.Visible = False
    End If

Catch ex As Exception
    MsgBox("No DATA Fetched" + ex.Message)
Finally
    con.Close()
End Try

There are two ways, both mentioned in commens.

1) Simple, but limited

If your grid is allways small enought to fit on form boundaries, put it into your Form.Controls instead of GroupBox.Controls. As suggested by @Farhan Ahmed Saifi

2) Full, but complicated

Create second form with the grid, tune BorderStyle and so on and show it on required coordinates. This will require more handling with Show/Hide/LostFocus/PositionChanged logic. As suggested by @jmcilhinney

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM