473,508 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cant find UserControl in toolbox

JR
Hi,

i found a user control on the net see code below
it is part of VSEssential but I like the coolProgressBar. Zo I want to use
it into my program and I always get the error that it can't find the control
or the control isn't into the toolbar

Who has an idee

Jan

'----------------start code--------------------------------

Imports System.Management

Imports System.Drawing

Imports System.Drawing.Drawing2D

Imports System.Drawing.Imaging

Imports System.Drawing.Text

Public Class CoolProgressbar

Inherits System.Windows.Forms.Panel

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

Me.Font = New System.Drawing.Font("Arial", 10.0!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))

End Sub

'UserControl overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

'

'CoolProgressbar

'

Me.Name = "CoolProgressbar"

End Sub

#End Region

#Region " Fillstyle Enumeration "

'enumeration for fillstyles

Public Enum fillstyle

Solid = 0

Gradient = 1

End Enum

#End Region

#Region " Declare Variables & Default Values "

Private m_value As Integer = 0

Private m_maximum As Integer = 100

Private m_fillstyle As LinearGradientMode = LinearGradientMode.Vertical

Private m_fill1 As Color = Color.Red

Private m_fill2 As Color = Color.Black

Private m_border As Color = SystemColors.ControlDark

Private m_borderwidth As Integer = 1

Private m_showpercent As Boolean = True

Private m_showborder As Boolean = True

Private m_TextColor As Color = Color.White

Private m_ShadowColor As Color = Color.Black

Private m_aText As String = ""

Private m_bText As String = ""

Private m_backfillstyle As LinearGradientMode =
LinearGradientMode.Horizontal

Private m_backfill1 As Color = SystemColors.ControlLight

Private m_backfill2 As Color = SystemColors.ControlDark

#End Region

#Region " Public Properties "

Public Property Gradient_BackFill_2() As Color

Get

Return m_backfill2

End Get

Set(ByVal Value As Color)

m_backfill2 = Value

Invalidate()

End Set

End Property

Public Property Gradient_BackFill_1() As Color

Get

Return m_backfill1

End Get

Set(ByVal Value As Color)

m_backfill1 = Value

Invalidate()

End Set

End Property

Public Property BackFill() As LinearGradientMode

Get

Return m_backfillstyle

End Get

Set(ByVal Value As LinearGradientMode)

m_backfillstyle = Value

Invalidate()

End Set

End Property

Public Property BeforeText() As String

Get

Return m_bText

End Get

Set(ByVal Value As String)

m_bText = Value

Invalidate()

End Set

End Property

Public Property AfterText() As String

Get

Return m_aText

End Get

Set(ByVal Value As String)

m_aText = Value

Invalidate()

End Set

End Property

Public Property ShadowColor() As Color

Get

Return m_ShadowColor

End Get

Set(ByVal Value As Color)

m_ShadowColor = Value

Invalidate()

End Set

End Property

Public Property TextColor() As Color

Get

Return m_TextColor

End Get

Set(ByVal Value As Color)

m_TextColor = Value

Invalidate()

End Set

End Property

Public Property Borderwidth() As Integer

Get

Return m_borderwidth

End Get

Set(ByVal Value As Integer)

m_borderwidth = Value

Invalidate()

End Set

End Property

Public Property Border() As Color

Get

Return m_border

End Get

Set(ByVal Value As Color)

m_border = Value

Invalidate()

End Set

End Property

Public Property Showborder() As Boolean

Get

Return m_showborder

End Get

Set(ByVal Value As Boolean)

m_showborder = Value

Invalidate()

End Set

End Property

Public Property ShowPercent() As Boolean

Get

Return m_showpercent

End Get

Set(ByVal Value As Boolean)

m_showpercent = Value

Invalidate()

End Set

End Property

Public Property Gradient_Fill_2() As Color

Get

Return m_fill2

End Get

Set(ByVal Value As Color)

m_fill2 = Value

Invalidate()

End Set

End Property

Public Property Gradient_Fill_1() As Color

Get

Return m_fill1

End Get

Set(ByVal Value As Color)

m_fill1 = Value

Invalidate()

End Set

End Property

Public Property Fill() As LinearGradientMode

Get

Return m_fillstyle

End Get

Set(ByVal Value As LinearGradientMode)

m_fillstyle = Value

Invalidate()

End Set

End Property

Public Property Maximum() As Integer

Get

Return m_maximum

End Get

Set(ByVal Value As Integer)

If Me.Value > Value Then Value = Me.Value

If Value < 1 Then Value = 1

m_maximum = Value

Invalidate()

End Set

End Property

Public Property Value() As Integer

Get

Return m_value

End Get

Set(ByVal Value As Integer)

If Value > Me.Maximum Then Value = Me.Maximum

m_value = Value

Invalidate()

End Set

End Property

#End Region

Public Sub Increment()

If Value < Maximum Then Value += 1

End Sub

Private Function ComputeAreaFill() As Rectangle

If Value > 0 Then

Return New Rectangle(0, 0, Width * Value / Maximum, Height)

Else

Return New Rectangle(0, 0, 1, Height)

End If

End Function

Private Function ComputeTotalArea(ByVal iOffset As Integer) As Rectangle

Return New Rectangle(0, 0, Width - iOffset, Height - iOffset)

End Function

Private Sub DrawFillComplete(ByVal e As Graphics)

Dim rect As Rectangle = ComputeAreaFill()

Dim SBrush As SolidBrush = New SolidBrush(Gradient_Fill_1)

Dim LBrush As LinearGradientBrush = New LinearGradientBrush(rect, m_fill1,
m_fill2, Fill)

Dim BBrush As LinearGradientBrush = New LinearGradientBrush(rect,
m_backfill1, m_backfill2, BackFill)

'draw the background

e.FillRectangle(BBrush, 0, 0, Me.Width, Me.Height)

If Value > 0 Then

'draw the actual progress state

e.FillRectangle(LBrush, rect)

End If

'draw the border if the user wants it

If m_showborder = True Then

e.DrawRectangle(New Pen(m_border, m_borderwidth), ComputeTotalArea(1))

End If

SBrush.Dispose()

LBrush.Dispose()

BBrush.Dispose()

End Sub

Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)

MyBase.OnPaint(e)

DrawFillComplete(e.Graphics)

If ShowPercent Then DrawPercentText(e.Graphics)

End Sub

Private Sub DrawPercentText(ByVal e As Graphics)

Dim sDisplayText As String

Dim TextPercent As Integer

If Value > 0 Then

TextPercent = Math.Round(Value / Maximum * 100)

sDisplayText = CStr(TextPercent)

Else

TextPercent = 0

sDisplayText = CStr(TextPercent)

End If

sDisplayText = sDisplayText & "%"

If m_bText <> "" Then sDisplayText = m_bText & " " & sDisplayText

If m_aText <> "" Then sDisplayText = sDisplayText & " " & m_aText

Dim strsize As SizeF = e.MeasureString(sDisplayText, Font)

Dim OffsetY As Integer

Select Case Me.BorderStyle

Case BorderStyle.Fixed3D : OffsetY = 3

Case Else : OffsetY = 0

End Select

'draw the text

e.DrawString(sDisplayText, Font, New SolidBrush(m_ShadowColor), ((Width -
strsize.Width) / 2), ((Height - strsize.Height) / 2 - OffsetY))

e.DrawString(sDisplayText, Font, New SolidBrush(m_TextColor), ((Width -
strsize.Width) / 2) - 1, ((Height - strsize.Height) / 2 - OffsetY) - 1)

End Sub

End Class


Nov 21 '05 #1
0 1798

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2691
by: Barney | last post by:
I created a usercontrol for my winForm (its a grid that will be used on multiple forms), now how can i add the usercontrol to the form(s)? thx
4
2133
by: steve bull | last post by:
I have created a UserControl and added it to my toolbox. It appears in the toolbox with the icon I created for it. The problem is that when I drag the control onto a form no code is generated. If I...
2
5945
by: Noozer | last post by:
This is a stupid question, I know, but I can't figure it out... Someone please embarass me. I have a solution that has a number of usercontrols included. When I add a usercontrol project to...
1
1149
by: Dennis | last post by:
I start a new project (Windows UserControl Library) and Name it "TestControl". I then open the vb code module and change the class name from UserControl1 to "TestControl" and the inheirits to a...
0
7132
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7063
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3211
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
432
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.