473,626 Members | 3,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to create a colour reference form

I'm trying to create many squares on a form and for every new square, change
the background colour to the next colour. I'm trying to create a colour
palette showing all available colours and their colour name.

My problem is that I can not figger out how to create a new panel at
specific intervals across and down the form. Here's the code I have so far:

Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim xNum As Byte = 4
Dim yNum As Byte = 2
Dim xLoc As Integer = 10
Dim yLoc As Integer = 10
Dim Spacer As Integer = 10
Dim ColourIndex As Object
Dim PanelHeight As Integer = 50

For y As Byte = 1 To yNum
For x As Byte = 1 To xNum
Dim NewPanelObj As New Panel
With NewPanelObj
.Left = xLoc
.Top = yLoc
.BackColor = CType(ColourInd ex, Color)
xLoc += .Width + Spacer
End With
Next
yLoc += PanelHeight + Spacer
Next
End Sub

Can someone help me?

--
|
+-- Thief_
|
Nov 21 '05 #1
4 1438
Thief_ wrote:
I'm trying to create many squares on a form and for every new square, change
the background colour to the next colour. I'm trying to create a colour
palette showing all available colours and their colour name.

My problem is that I can not figger out how to create a new panel at
specific intervals across and down the form. Here's the code I have so far:

Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim xNum As Byte = 4
Dim yNum As Byte = 2
Dim xLoc As Integer = 10
Dim yLoc As Integer = 10
Dim Spacer As Integer = 10
Dim ColourIndex As Object
Dim PanelHeight As Integer = 50

For y As Byte = 1 To yNum
For x As Byte = 1 To xNum
Dim NewPanelObj As New Panel
With NewPanelObj
.Left = xLoc
.Top = yLoc
.BackColor = CType(ColourInd ex, Color)
xLoc += .Width + Spacer
End With
Next
yLoc += PanelHeight + Spacer
Next
End Sub

Can someone help me?


Well you never add the panel to the form. Add a panel to the form
through the designer. Then open up the Windows Generated Code and see
how they add the control to the form.

Another idea would be to override the onpaint method of the form. Then
do something like:

e.Graphics.Fill Rectangle(Brush es.Black,...... )

Good Luck
Chris
Nov 21 '05 #2
Thanks Chris,

I now have an automated procedure to place (RED) coloured panels over my
form. My last question is, how do I alternate the colour of each panel so
that all NET colours are displayed, along with their NET name?

Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim xNum As Byte = 10
Dim yNum As Byte = 10
Dim xLoc As Integer = 10
Dim yLoc As Integer = 10
Dim Spacer As Integer = 10
Dim ColourIndex As Object
Dim PanelHeight As Integer = 50

For y As Byte = 1 To yNum
For x As Byte = 1 To xNum
Dim NewPanel As New System.Windows. Forms.Panel
Me.Controls.Add (NewPanel)
With NewPanel
.BorderStyle = BorderStyle.Fix ed3D
.Width = 50
.Height = 50
.Left = xLoc
.Top = yLoc
.BackColor = Color.Red ' CType(ColourInd ex, Color)
xLoc += .Width + Spacer
ColourIndex += 1
End With
Next
xLoc = 10
yLoc += PanelHeight + Spacer
Next
End Sub

--
|
+-- Thief_
|

"Chris" <no@spam.com> wrote in message
news:uB******** ******@tk2msftn gp13.phx.gbl...
Thief_ wrote:
I'm trying to create many squares on a form and for every new square, change the background colour to the next colour. I'm trying to create a colour
palette showing all available colours and their colour name.

My problem is that I can not figger out how to create a new panel at
specific intervals across and down the form. Here's the code I have so far:
Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim xNum As Byte = 4
Dim yNum As Byte = 2
Dim xLoc As Integer = 10
Dim yLoc As Integer = 10
Dim Spacer As Integer = 10
Dim ColourIndex As Object
Dim PanelHeight As Integer = 50

For y As Byte = 1 To yNum
For x As Byte = 1 To xNum
Dim NewPanelObj As New Panel
With NewPanelObj
.Left = xLoc
.Top = yLoc
.BackColor = CType(ColourInd ex, Color)
xLoc += .Width + Spacer
End With
Next
yLoc += PanelHeight + Spacer
Next
End Sub

Can someone help me?


Well you never add the panel to the form. Add a panel to the form
through the designer. Then open up the Windows Generated Code and see
how they add the control to the form.

Another idea would be to override the onpaint method of the form. Then
do something like:

e.Graphics.Fill Rectangle(Brush es.Black,...... )

Good Luck
Chris

Nov 21 '05 #3
"Thief_" <th****@hotmail .com> schrieb
I now have an automated procedure to place (RED) coloured panels
over my form. My last question is, how do I alternate the colour of
each panel so that all NET colours are displayed, along with their
NET name?

Getting all names into an Array of Strings:

Dim T As Type
Dim PInfos As Reflection.Prop ertyInfo()
Dim al As New ArrayList
Dim Names As String()

T = GetType(Color)

PInfos = T.GetProperties ( _
Reflection.Bind ingFlags.Static Or Reflection.Bind ingFlags.Public _
)

For Each PInfo As Reflection.Prop ertyInfo In PInfos
If PInfo.PropertyT ype Is T Then
al.Add(PInfo.Na me)
End If
Next

Names = DirectCast(al.T oArray(GetType( String)), String())
Use Color.FromName to get a color from the name.

If you want to use the System.Drawing. KnownColor Enum, this is how you can
get the names/values:

Dim KnownColors As KnownColor()

Names = [Enum].GetNames(GetTy pe(KnownColor))
KnownColors = DirectCast([Enum].GetValues(GetT ype(KnownColor) ),
KnownColor())

Armin

Nov 21 '05 #4
Hi,

This doesnt get the name for you but this example might help.

http://www.bobpowell.net/giftransparency.htm

Ken
------------------
"Thief_" <th****@hotmail .com> wrote in message
news:eR******** ******@TK2MSFTN GP09.phx.gbl...
I'm trying to create many squares on a form and for every new square, change
the background colour to the next colour. I'm trying to create a colour
palette showing all available colours and their colour name.

My problem is that I can not figger out how to create a new panel at
specific intervals across and down the form. Here's the code I have so far:

Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim xNum As Byte = 4
Dim yNum As Byte = 2
Dim xLoc As Integer = 10
Dim yLoc As Integer = 10
Dim Spacer As Integer = 10
Dim ColourIndex As Object
Dim PanelHeight As Integer = 50

For y As Byte = 1 To yNum
For x As Byte = 1 To xNum
Dim NewPanelObj As New Panel
With NewPanelObj
.Left = xLoc
.Top = yLoc
.BackColor = CType(ColourInd ex, Color)
xLoc += .Width + Spacer
End With
Next
yLoc += PanelHeight + Spacer
Next
End Sub

Can someone help me?

--
|
+-- Thief_
|

Nov 21 '05 #5

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

Similar topics

4
3194
by: Craig | last post by:
I have a page that has a few columns and totals. I've been asked to amke sure that not only is the totals boxes readonly, they must not accept focus from the cursor. However, setting the bo to Disabled makes the font go inverted it seems. I'd like to be able to still control the colour of these boxes, both the background and foreground, but not makethem the light grey that they are going at the moment.
5
4834
by: Steve Amey | last post by:
Hi all I have an ARGB value for a Colour (Eg. -65536. The value was retrieved by using the Color.ToArgb method), is there any way that I can create a System.Drawing.Image or a System.Drawing.Bitmap from that value? Regards, Steve
6
2790
by: Lapchien | last post by:
One of my users has asked that a form change it's colour if a particular yes/no box is ticked - possibly made a bit more tricky because the form is tabular..? Thanks, Lap
3
2485
by: MS | last post by:
I need to determine CMYK values from bitmaps. Is there a way in VB or Access to do this? The reason is that I need to determin the relative CMYK values. Example: A square with the bottom half filled with black would have a black value of 50%. The same square with the bottom half filled with red would have values C=0, M=50%, Y=50%, K=0 and so on. At the moment we're putting a small version of the image into a paint
3
2597
by: Tim Marshall | last post by:
I would swear that when I developed in A97, I could change the back colour of a form. However, in Windows XP, on both A97 and A2003, there no longer is a property showing in the format tab for form properties for a back colour. I think the themed control idea is pretty good in that a developer can really go out on a limb if s/he chooses all kinds of fancy background colours for his/her app since colours selection is a very subjective...
26
8072
by: johkar | last post by:
I need to cancel the link and execute a function onclick of all the links within the span tag which has a class of "container" assigned. There will be only one span tag with this class applied. I know you can get a specific tag using document.getElementsByTagName('span'), but I am unsure how to get the one with the class="container". I know there is a getAttribute method, just need a pointer or two to put it all together. Once I know...
6
3677
by: windandwaves | last post by:
Hi Folk Some of my clients asked me to create "fancy emails" for them (aka html formatted emails). I know how to make a nice html document, but I had trouble creating a simple way to provide the document to my clients so that they could use it to. I know most of them use Outlook XP or Outlook 2003, so what I created was a page that creates a Visual Basic script that, when saved to the desktop and
0
1431
by: Kristian Frost | last post by:
Hi, I'm just getting started with VB.Net, and I'm having trouble getting the routing around of some of the data straight in my mind, which has led me to the following problem. Basically, I'm trying to create an object that will monitor the status of some switches. I created a User Control to put into a form, on which I want to have five graphical representations of LEDs, which I've got working, light up and turn off when the...
3
2599
by: bettyboo | last post by:
Hi I'm new to the forum and also a VERY new user of Access to develop databases. I'm building a DB for a driving instructor acquaintance, and he wants a button on the pupil data entry form which he can click to flag a pupil as "Do Not Rebook" (i.e. if they're a non-payer or something). Upon clicking the button, he wants a value to be recorded in the appropriate field in the table (so we can report on it later) and he also wants the...
0
8196
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8364
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7193
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5574
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2625
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.