[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 980
  • Last Modified:

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
0
StateGuy
Asked:
StateGuy
  • 4
  • 2
1 Solution
 
broadbentCommented:
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
0
 
broadbentCommented:
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
0
 
StateGuyAuthor Commented:
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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
broadbentCommented:
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.
0
 
StateGuyAuthor Commented:
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
0
 
broadbentCommented:
A word of warning. As I recall, Threed32.ocx is old tochnology.
If you want to have a bevel (not a border) then paint it on.
In VS, GDI+ now encapsulates all those Windows APIs used for drawing, and you might as well learn how to use them.

I suggest using a panel, because it has fewer overheads. using Inherits.
paint the bevel in the paint event using
Dim g as graphics = e.graphics ( e is an argument in the paint event)
Then use either a solidbrush or hatch brush to paint the bevels

Then in the MouseEnter, MouseLeave, MouseDown events
set the colour, size, show (whatever) global variables and then Refresh()
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now