簡體   English   中英

如何在類似GroupBox的父控件之外顯示DataGridView

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

獲取附件快照

如何在諸如DropDownList類的父控件(例如GroupBox )之外顯示DataGridView

每當我雙擊文本框時,我都希望顯示具有完整大小及其內容的DataGridView ,但是DataGridView會部分顯示並隱藏在GroupBox(其父控件)之外。

請參考所附的快照。

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

有兩種方式,都提到。

1)簡單,但有限

如果網格始終足夠小以適合表單邊界,請將其放入Form.Controls中,而不是GroupBox.Controls中。 正如@Farhan Ahmed Saifi所建議

2)完整但復雜

使用網格創建第二個表單,調整BorderStyle等,然后在所需坐標上顯示它。 這將需要使用Show / Hide / LostFocus / PositionChanged邏輯進行更多處理。 如@jmcilhinney所建議

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM