views:

38

answers:

3

I am looking for a WinForms control that, I believe, in the days of VB 6.0 (I can't remember if it was VB 6 or .NET 1.1) used to be called the ButtonImage or ImageButton or some such. Whatever it was called is not important.

What it used to look like and behave like is the important thing.

If you open Control Panel -> Add Remove Programs in Windows XP, the buttons on the left Change or Remove Programs, Add New Programs, etc. use tat control. I want a control that looks like that. It's a button with an image but stays pressed when it is selected.

Secondly, I am looking for a splitter. I see one in the Toolbox in Windows Forms apps, but when I try to change its size at runtime, it won't.

Do I have to use a SplitterContainer first or something?

+2  A: 

Unfortunately this control doesn't exist in Windows Forms. You will probably find one in commercial control libraries, look for Outlook-type menus.

For the splitter, you have to use a SplitterContainer, which is two panels separated by a splitter. Then you add your controls on both splitters and will be able to move the splitter and everything.

Gimly
+1  A: 

For starters you can make the button use an image by tweaking the properties like so

Button1.Text = ""
Button1.Size = New Size(100, 100)
Button1.TextImageRelation = TextImageRelation.ImageAboveText
Button1.Image = My.Resources.Image1

That would make the button look like this

alt text

You could also swap out the image every time the user clicks with the buttons click event.

Make sure to replace image1 and image2 with the real images.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    If Button1.Image = image1 Then
        Button1.Image = image2
    Else
        Button1.Image = image1
    End If
End Sub

You if you want the image to border and hover to be different try messing around with the button.FlatStyle = flat and the FlatAppearance property's.

giodamelio
+3  A: 

You may make use of RadioButton control or CheckBox control.

Add the control and change the Appearance property of RadioButton to Button. Add a BackgroundImage to that.

Chaitanya
Thats cool. My way was so much harder -_-
giodamelio