dave299 | Wed, 05 Sep 2007 10:33:00 GMT |
Sorry
i am new to VB so don't know all the default dialog boxes available.
Is there a list with all the dialogue boxes some where?
How would i use the colour dialogue box? just place a button
the type = colour dialogue
Andy
xplosiv_1 | Wed, 05 Sep 2007 10:34:00 GMT |
Just enter dialogs into the Help search and you should find them all.
Basic use as follows:
Dim CD As New ColorDialog
Dim SelectedColor As Color
If CD.ShowDialog() = Windows.Forms.DialogResult.OK Then
SelectedColor = CD.Color
End If
dave299 | Wed, 05 Sep 2007 10:35:00 GMT |
Change the background color of the form to the color the user selected in the color dialog..
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.ClickDim cd As New ColorDialogWith cd.
AllowFullOpen = True.
Color = Me.BackColor.
FullOpen = True.
ShowDialog()End WithMe.BackColor = cd.ColorEnd Subdman1 | Wed, 05 Sep 2007 10:36:00 GMT |
Is there a colour box which displays the list you get in visual sudio when you type
color. Aqua blue
Brick red
etc
?
Thanks,
ANdy
xplosiv_1 | Wed, 05 Sep 2007 10:37:00 GMT |
Not that I'm aware of but try this:
Public Class Form1
Dim Colours() As KnownColor
Dim F As New Font("Arial", 12, FontStyle.Bold)
Dim WithEvents CMBO As New ComboBox
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CMBO.SetBounds(50, 50, 200, 20)
CMBO.DrawMode = DrawMode.OwnerDrawFixed
CMBO.Font = F
Me.Controls.Add(CMBO)
Colours = DirectCast([Enum].GetValues(GetType(KnownColor)), KnownColor())
For Each C As KnownColor In Colours
CMBO.Items.Add([Enum].GetName(GetType(KnownColor), CInt(C)))
Next
End Sub
Private Sub CMBO_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles CMBO.DrawItem
e.DrawBackground()
Dim C As Color = Color.FromName(CMBO.Items(e.Index).ToString)
Dim B As New SolidBrush(C)
e.Graphics.FillRectangle(B, New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
e.Graphics.DrawString(CMBO.Items(e.Index).ToString, F, Brushes.Black, e.Bounds.X, e.Bounds.Y)
End Sub
Private Sub CMBO_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CMBO.SelectedIndexChanged
Me.Text = CMBO.SelectedItem.ToString
End Sub
End Class
dave299 | Wed, 05 Sep 2007 10:38:00 GMT |
Private WithEvents zColorCombobox1 As New xxColorCombobox
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
zColorCombobox1.ColorsToShow = xxColorCombobox.KnownColorsToShow.SystemColorsOnly
zColorCombobox1.Dock = DockStyle.Top
zColorCombobox2.ColorsToShow = xxColorCombobox.KnownColorsToShow.NamedWebColorsOnly
zColorCombobox2.Dock = DockStyle.Bottom
zColorCombobox3.ColorsToShow = xxColorCombobox.KnownColorsToShow.All
zColorCombobox3.BackColor = Color.FromArgb(64, 64, 64)
zColorCombobox3.ForeColor = Color.White
zColorCombobox3.Font =
End Sub Private Sub zColorComboboxes_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles zColorCombobox1.SelectedIndexChanged, zColorCombobox2.SelectedIndexChanged, zColorCombobox3.SelectedIndexChanged
Public
Class xxColorComboboxPublic Enum KnownColorsToShow
nogchoco | Wed, 05 Sep 2007 10:39:00 GMT |
dave299 | Wed, 05 Sep 2007 10:40:00 GMT |
Dave299 wrote:
Very nice - I'd been trying to think of an elegant way to make sure the text would always be readable.
nogchoco | Wed, 05 Sep 2007 10:41:00 GMT |
nogChoco,
As i am rubbish at vb (new and all)
How would i make your code eqal my colourcbo?
As in: i created your project and it displays three combo box's all i need is to produce the result you get in the combobox at the bottom (that displays aliceblue) in my
colourcbo (
and be able to make selected colour variable equal to the selsect colour.
By the way, very nice code
Many Thanks,
Andy
xplosiv_1 | Wed, 05 Sep 2007 10:42:00 GMT |
The xxColorCombobox class that I created (under the Form1 Class code) can be used like a normal combobox. If you're using VB2005, then build or run the solution once, and then you should see 'xxColorCombobox' in the toolbox like the other controls (it will be in a section that is named after your project).
Or you can create it via code, like you would with a normal combobox. xxColorCombobox has a .SelectedColor property that gives you the color that is currently selected in the ColorCombobox:
Private aNewCombo as New xxColorCombobox
Private aColor as Color = aNewCombo.SelectedColor
And you can use the .ColorsToShow property to limit the colors to SystemColors or NamedWebColors only (or All of them). The SelectedIndexChanged event can be used to keep your color-variable up to date with the color you selected in the combobox:
Private Sub aNewCombo_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles aNewCombo.SelectedIndexChanged
Dim zColorCombobox As xxColorCombobox = sender
aColor = zColorCombobox.SelectedColor
End Sub
nogchoco | Wed, 05 Sep 2007 10:43:00 GMT |
nogChoco,
Took me a few minutes to figure out how to 'dll build' it
to add to my toolbox. (versus just using it as a class.)
But man, that code rocks!
talldude | Wed, 05 Sep 2007 10:45:00 GMT |
EDIT: The list only doubles when the control is added at designtime, so I'm not sure I'll be able to figure it out
nogchoco | Wed, 05 Sep 2007 10:45:00 GMT |
Make this change to fix the code:
Private Sub Update_ColorList()TryMe.Items.Clear()Dim zArrayList As New ArrayList(40)zArrayList.Clear()
The Sub New() and the ColorsToShow() are
both calling Me.Update_ColorList when the
control is initialized and because zArrayList
already exists, the code is not waiting for another
new one to get initialized.
Edited comment:
Well it fixed it in one test. Now I don't know ....?
talldude | Wed, 05 Sep 2007 10:47:00 GMT |
:eek2: http://www.vbforums.com/showthread.php?p=2829958#post2829958Well, you seem just to have triggered it through a particular set of circumstances, whatever they may be...Lex Luthor strikes again!!!:)...
He was always here with us. (http://www.vbforums.com/member.php?u=13510) :afrog:...
Happy Birthday seor!...
I have more zells than you....
I'm looking for a video/mp3 player.Does anyone know what video formats Ipod / Zune supports?I have a large variety of codecs and video formats, OGMs with *.sub subtitle text files, MKVs, the most importantly DIVX AVIs.Am I wrong or do Ipod only support MOV videos, and Zune only support WMV...
I'm sure you have all heard of the sad demise of Mr Douglas Adams, earlier this week, of a heart attack at age 49.He was a source of inspiration to me in particular, having grown up repeatedly listening to the Hitch Hiker's Guide To The Galaxy, and reading all his books.He will be miss...
Anyone know when it's coming out?...
I have the z-score value and what i need is the correspondingprobability. I can determine it with a table like this one:http://www.epatric.com/documentatio...core_table.htmlBut i was wondering if there was a function in visual basic or a peiceof code that can calculate it for me without needing...
OK, I've made my own gaming engine with it's own pseudo-windows and what not. When it comes to render the windows onto the device context it becomes tricky if I want one window to appear in front or behind another window. I thought about ZOrdering but when a window is created what ZO...
Can someone explain what exactly Z-Order is...? And what exactly is it used for...?Cheers......
Hi Guys,Just a quick and hopefully simple question, I'm working on an application that needs to always be at the very bottom of the zorder, i know how to send my app to the top but I need to know how to send it to the very bottom.Thanks....
I am creating an activex control in which I have a 3rd party image control and a label control. I want the label control to be on top of the image control but it's always hidden beneath the image control. Is there any way I can make it come over top of the image contro?? I have played ar...
Does Win 2k handle Zorder differently? All of my windows keep appearing at the bottom of the Zorder instead of the top when I spawn them.What the heck is going on?Eiredrake...
some components e.g. the "spinButton" are not able to bring to front! Also i set z-order in code and choose option "Bring to front" With other components it's no problem!!! Can you help me?...
hello,i have 2 forms that i want to display in 2 different ways.form1 shows form2 with vbmodal as default.then on form2 i have a check button thay says: 'always on top'.when you click on it you change the default setting either to on top or not on top.i only managed to get this work af...