开发者

What's the equivalent of VB6.0 frame control in .Net?

What's the equivalent of VB6.0 frame control in .Net? panel or groupbox?

I recall that using frame in VB6.0 and disable it (frame1.Enabled = False) did not change its fore color of controls within it 开发者_开发问答.


Have you looked at the System.Windows.Forms.GroupBox?

This page could be of use to you. It explains the transition from the VB6 Frame control to the newer .NET controls.


It is considered a crime against usability to not make a control appear disabled when it is disabled. Nothing quite like the sight of user banging away on the mouse button to try to get the program to do what she thinks is possible.

Windows Forms doesn't support it, but you can fake it. You could display an image of the enabled controls, overlapping the disabled ones. Add a new class to your project and paste the code shown below. Compile. Drop the control from the top of the toolbox onto your form and add controls to it. Try it out by having a button toggle the Enabled property.

Public Class MyPanel
  Inherits Panel

  Private mFakeIt As PictureBox

  Public Shadows Property Enabled() As Boolean
    Get
      Return MyBase.Enabled
    End Get
    Set(ByVal value As Boolean)
      If value Then
        If mFakeIt IsNot Nothing Then mFakeIt.Dispose()
        mFakeIt = Nothing
      Else
        mFakeIt = new PictureBox()
        mFakeIt.Size = Size
        mFakeIt.Location = Location
        Dim bmp = new Bitmap(Width, Height)
        Me.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height))
        mFakeIt.Image = bmp
        Me.Parent.Controls.Add(mFakeIt)
        Me.Parent.Controls.SetChildIndex(mFakeIt, 0)
      End If
      MyBase.Enabled = value
    End Set
  End Property
End Class

Please don't use this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜