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(ByVal sender As Object, ByVal e As
System.EventArgs) 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.Fixed3D
.Width = 50
.Height = 50
.Left = xLoc
.Top = yLoc
.BackColor = Color.Red ' CType(ColourIndex, 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**************@tk2msftngp13.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(ByVal sender As Object, ByVal e As
System.EventArgs) 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(ColourIndex, 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.FillRectangle(Brushes.Black,......)
Good Luck
Chris