English 中文(简体)
创建带有标题的数据GridView( 以 GroupBox 嵌入)
原标题:Create a DataGridView with a Caption (Embed in GroupBox)

我有一个数据GridView,我想把它放入一个群包中。在VB6中,它看起来是这样的:

VB6中带标题的FlexGrid女士

所以这只是由一组包包的FlexGrid女士。我完全不知道如何在 VB.NET 中实施。

我让它继承DataGridView, 所以它是一个控制, 它默认拥有数据GridView的所有属性 。

Public Class CaptionedDataGridView
    Inherits DataGridView

还必须有一个 GroupBox :

Private xGroupBox as GroupBox

文本属性将被组框的文本以及某些大小和位置属性( Top、 Left、 Width、 Height) 取代

Public Overrides Property Text As String
  Get
    Return xGroupBox.Text
  End Get
  Set(ByVal value As Integer)
    xGroupBox.Text = value
  End Set
End Property

最后,如果我在某个地方创建一个新的CaptionedDataGridView,它应该与群包团团圆一起画画。我如何从我现在所处的位置到我想成为的地方?

最佳回答

我认为你必须这样做,从组框继承,然后加上数据GridView。

简单示例 :

Public Class MyGrid
  Inherits GroupBox

  Private _Grid As DataGridView

  Public Sub New()
    _Grid = New DataGridView()
    _Grid.Dock = DockStyle.Fill
    Me.Controls.Add(_Grid)
  End Sub

  ReadOnly Property Grid As DataGridView
    Get
      Return _Grid
    End Get
  End Property

End Class

当然, 您不必作为自定义控制来这样做。 您可以在您的表格上放一个 GroupBox, 并添加一个 DataGridView 和相同的 DockStyle 。 Fiell 属性 。

问题回答

暂无回答




相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签