![](/img/trans.png)
[英]How to check the controls (display name and type) in the GroupBox by recursion and display on a 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.