Link to home
Start Free TrialLog in
Avatar of StateGuy
StateGuyFlag for United States of America

asked on

How do I create/modify a VB .Net object?

This question may be elementary to some of you, which would be great for me.

I would like to add a property to a VB .Net object, or create an object based on a current object.  I'd like to be able to add a property to a panel that changes the bevel; such as raised or inset.  Right now, the only 3D property is inset.  I'd like to be able to programmatically change it from inset to raised and back.  I'm pretty good with VB6, but since VB6 didn't do inheritance very well, it's new to me.  VB6 in Visual Studio 6 Enterprise has a control set called "Sheridan 3D controls," found in the file "Threed32.ocx," which has a panel that does what I want.  But it's not in .Net.

When I worked in Delphi, I only had to search the Internet for a control that would do what I wanted (sites like Torry's Delphi pages or Superpage), so I didn't really need to understand inheritance.  I can't seem to find any similar sites for VB .Net, so I'd like know where I could go to find what I need.  Or could anyone steer me to any type of tutorial for modifying .Net objects?  Or can the Sheridan controls be used in VB .Net (such as adding "Threed32.ocx" to the form object list)?

Many thanks in advance for your help (or condolences)...

Randy
Avatar of broadbent
broadbent
Flag of United Kingdom of Great Britain and Northern Ireland image

Generically

Private HasBevel as Boolean

Public Property MyProperty() as Boolean
 Get
  Return HasBevel
 End get
 Set(Byval Value as Boolean)
  HasBevel = Value
  Refresh()
 End Set
End Property

and in the paint event, use hasbevel to darw bevel or whatever
Oops.

I assujmed you already had a userControl, or object.
If you have, this simply change
Inherits System.Windows.Forms.UserControl  to Inherits System.Windows.Forms.Panel
Avatar of StateGuy

ASKER

I, too, am pretty much self-taught, which probably explains my dilemma.  I didn't quite understand what you gave me, so I tried this:

Public Class MyPanel
    Inherits System.Windows.Forms.Panel
    Private HasBevel As Boolean

    Public Property Bevel3D() As Boolean
        Get
            Return HasBevel
        End Get
        Set(ByVal Value As Boolean)
            HasBevel = Value
            Refresh()
        End Set
    End Property

End Class

It successfully saved and compiled, which really confuses me.  The panel name is "Panel1" (VB .Net default name) and I need the bevel to change in the "Panel1_Click" event.  

If this is right, how do I use it?  If this is wrong (which I assume is the case), how do I fix it?  

BTW, thanks for the quick response.
So you want to change the border of a panel?
In which case why not simply change its borderstyle.
If you want to click on the panel to do this then all you need do is add the following code in the Panel_Click event
Select case panel1.borderstyle
case borderstyle.fixed3d: panel1.borderstyle=borderstyle.none
etc..
You don't need to create your own panel with a special property.
No, I wanted to change the inset/raised bevel, not the border.  Anyway, what I ended up doing was first, I found the System32\Threed32.ocx file and referenced it: References - Threed
Second, added the right "Imports" statement: "Imports Microsoft.VisualBasic"
Third, Right clicked on the "Windows Forms" tab and selected the controls I needed from the COM list.

It was a wild hunch, but I figured I had nothing to lose.  There wasn't really a direct answer, but you made me think in a different direction.  As far as I'm concerned, you've earned the points.  I don't know how to award them without a definitive answer, but you get the 500 points for the help.  Thanks for the push in the right direction.

Randy
ASKER CERTIFIED SOLUTION
Avatar of broadbent
broadbent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial