简体   繁体   English

如何在类似GroupBox的父控件之外显示DataGridView

[英]How to display DataGridView outside the parent control like GroupBox

获取附件快照

How can I display DataGridView outside the parent control (eg. GroupBox ) like DropDownList . 如何在诸如DropDownList类的父控件(例如GroupBox )之外显示DataGridView

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). 每当我双击文本框时,我都希望显示具有完整大小及其内容的DataGridView ,但是DataGridView会部分显示并隐藏在GroupBox(其父控件)之外。

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 1)简单,但有限

If your grid is allways small enought to fit on form boundaries, put it into your Form.Controls instead of GroupBox.Controls. 如果网格始终足够小以适合表单边界,请将其放入Form.Controls中,而不是GroupBox.Controls中。 As suggested by @Farhan Ahmed Saifi 正如@Farhan Ahmed Saifi所建议

2) Full, but complicated 2)完整但复杂

Create second form with the grid, tune BorderStyle and so on and show it on required coordinates. 使用网格创建第二个表单,调整BorderStyle等,然后在所需坐标上显示它。 This will require more handling with Show/Hide/LostFocus/PositionChanged logic. 这将需要使用Show / Hide / LostFocus / PositionChanged逻辑进行更多处理。 As suggested by @jmcilhinney 如@jmcilhinney所建议

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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