Image for Wizard button

Wizard for Windows Forms Forum

Posted 19 years ago by frabu
Avatar
I am afraid that is not possible to set an image under "previous", "next", "cancel" buttons. But I do need to set such images instead of just a text and a color background.

Any solution ?

Regards
Frank Buff

Comments (9)

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Right now we're using Microsoft's Button class. You can probably iterate through the child controls of the Wizard to look for the Button controls and set their Images appropriately. We will add better functionality for this in the future.

[ 01-23-2005: Message edited by: Actipro Software Support ]


Actipro Software Support

Posted 19 years ago by frabu
Avatar
Hi,

You wrote: "You can probably iterate through the child controls of the Wizard to look for the Button controls"

I stopped the debugger and drill down my Wizard object through QuickWatch.
I found some clue but I'm not very sure that I'm on the right track. Furthermore, when I compile I get the error
F:\Frank Documents\Visual Studio Projects\Fotowire\Fotowire\CheckOutWizard.cs(166): 'ActiproSoftware.Wizard.Wizard._5' is inaccessible due to its protection level

Could you give me an example showing how to assign programmaticaly an image to a wizard's button. ?

It would be great
Regards
Frank
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
This code changes the buttons to show images. The images don't show when the FlatStyle is System, but that is Windows Forms code that causes that behavior.

this.Wizard.ButtonFlatStyle = FlatStyle.Standard;
foreach (Control control in this.Wizard.Controls) {
    if (control is Button)
        ((Button)control).Image = Image.FromFile(@"pathtofilehere");
}


Actipro Software Support

Posted 17 years ago by Warren J. Hairston - President, Logical Operators, Inc.
Avatar
Was a feature to make this easier ever implemented?

My customer just e-mailed me some professionally-designed graphics for each of the wizard buttons, but I'm having trouble distinguishing which button is which using the workaround code above. Since I have different graphics for each button, this has quickly become a critical issue for me.

Ideally, it would be best if Wizard had exposed properties (NextButton, BackButton, etc.) that would return the actual Button objects so I could manipulate the Button's AutoSize, Image, and TextImageRelation properties myself. (Those are just the three properties I've needed to apply my customer's graphics to other buttons in my application - other developers might need to access different Button properties.)

If for some reason that's not possible to implement, would it be possible to add some Wizard properties that would at least allow me to specify Image, ButtonHeight, and ButtonTextImageRelation?

If changing the button height would create issues with the Wizard layout, I could probably apply scaled-down versions (16x16 pixels?) of the graphics to each button.

In short, I'm just looking for the easiest way to do this. Looking forward to your response - my thanks in advance!
- Warren
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Warren,

The upcoming maintenance release (probably tomorrow or the next day) will contain new properties like NextButton, BackButton, etc. which are direct references to the Button controls.


Actipro Software Support

Posted 17 years ago by Warren J. Hairston - President, Logical Operators, Inc.
Avatar
I just downloaded the new Wizard v3.0.124 release, and the new NextButton, BackButton, etc. properties were just what I needed! My client is happy - thanks for responding with an update and new features so quickly!

I do have a suggestion for further ease-of-use with regard to this feature. It seems that by itself, the Wizard is unable to respond to changes that I make directly to the various Button controls. In my code, I did the following to make the Wizard render properly:

int OriginalWizardButtonHeight = Wizard.ButtonHeight;

//set custom images for Wizard buttons
Wizard.BackButton.AutoSize = true;
Wizard.BackButton.TextImageRelation = TextImageRelation.ImageBeforeText;
Wizard.BackButton.Image = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("back_image.png"));
//...do the same thing again for CancelButton, NextButton, etc.


//reflect changes in button sizes to Wizard
Wizard.ButtonHeight = Wizard.NextButton.Height;
Wizard.BackButtonWidth = Wizard.BackButton.Width;
Wizard.CancelButtonWidth = Wizard.CancelButton.Width;
Wizard.NextButtonWidth = Wizard.NextButton.Width;

//update Renderer for increase in height of buttons
Wizard.Renderer.WizardButtonContainerHeight += (Wizard.ButtonHeight - OriginalWizardButtonHeight);
In the next maintenance release, would it be possible to add one or more event handlers within Wizard to catch the Resize or SizeChanged events of the various Wizard buttons so the Wizard.ButtonHeight/Widths and Wizard.Renderer.WizardButtonContainerHeight properties could be automatically updated without the need for the programmer to re-specify the sizes? This would just be that much less code I'd have to write. ;)

Thanks again for your quick response!
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hmm... I'm not sure if that would be a good thing to do on our end because if we start automatically increasing the button container height then we might cut off page controls that appear near the bottom of a page. Like sometimes labels such as "Press Next to continue" appear down there.

In an environment like WPF, I would agree with this way of thinking though because in that, automatic layout is possible so the entire parent Form could grow as needed. But in Windows Forms that feature isn't available.


Actipro Software Support

Posted 17 years ago by Warren J. Hairston - President, Logical Operators, Inc.
Avatar
That makes sense - I did have to adjust a couple of my pages for just that reason. No big deal, this is certainly usable as-is.

By the way, was the Wizard Documentation file updated for the new features in this release? I couldn't find references to the new properties when I first downloaded the release?

Thanks again!
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Whoops... looks like we forgot to rebuild the docs for those property additions. We'll mark it down for the next maintenance release. Sorry, at least their usage is very straightforward.


Actipro Software Support

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.