Submitted by Collin (not verified) on Thu, 2008-12-18 14:24.
The stack idea is exactly what I was thinking for the back button. However for next I decided to create a different InternalWizardPage. I created one that inherits from it (just to keep it simple) set up the buttons with in it (cause that annoyed me to have to do every time I made a new page).
The true key was creating 2 Lists
List _rbList = new List(); //Used to link the radio button to the next page
List _nextPages = new List(); //Actual next page
as well as a method to add radio buttons dynamically
public void AddRadioButton(RadioButton rb, string nextPage)
{
AdjustLocation();
rb.Location = _location;
rb.TabIndex = _tabIndex++;
rb.CheckedChanged += new EventHandler(rb_CheckedChanged);
this.Controls.Add(rb);
_rbList.Add(rb); //Add to the list for easy reference
_nextPages.Add(nextPage);
Refresh();
}
void rb_CheckedChanged(object sender, EventArgs e)
{
if (((RadioButton)sender).Checked)
_selectedRB = (RadioButton)sender;
}
private void AdjustLocation()
{
_location = new Point(_location.X, _location.Y + _locOffset.Y);
if (_location.Y > _bounds.Y)
throw new ArgumentException("Added too many RadioButtons and the control will now draw out of bounds");
}
So then the instantiator of this component just needs to send in a RadioButton with its linked page. I created a MakeRadioButton method to set up the basics then I just set the name and text manually before sending it to the page instatiation.
private RadioButton MakeRadioButton()
{
RadioButton rb = new RadioButton();
rb.AutoSize = true;
rb.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
rb.Size = new System.Drawing.Size(335, 24);
rb.TabStop = true;
rb.UseVisualStyleBackColor = true;
return rb;
}
The stack idea is exactly
The stack idea is exactly what I was thinking for the back button. However for next I decided to create a different InternalWizardPage. I created one that inherits from it (just to keep it simple) set up the buttons with in it (cause that annoyed me to have to do every time I made a new page).
The true key was creating 2 Lists
List _rbList = new List(); //Used to link the radio button to the next page List _nextPages = new List(); //Actual next pageas well as a method to add radio buttons dynamically
public void AddRadioButton(RadioButton rb, string nextPage) { AdjustLocation(); rb.Location = _location; rb.TabIndex = _tabIndex++; rb.CheckedChanged += new EventHandler(rb_CheckedChanged); this.Controls.Add(rb); _rbList.Add(rb); //Add to the list for easy reference _nextPages.Add(nextPage); Refresh(); } void rb_CheckedChanged(object sender, EventArgs e) { if (((RadioButton)sender).Checked) _selectedRB = (RadioButton)sender; } private void AdjustLocation() { _location = new Point(_location.X, _location.Y + _locOffset.Y); if (_location.Y > _bounds.Y) throw new ArgumentException("Added too many RadioButtons and the control will now draw out of bounds"); }So then the instantiator of this component just needs to send in a RadioButton with its linked page. I created a MakeRadioButton method to set up the basics then I just set the name and text manually before sending it to the page instatiation.
private RadioButton MakeRadioButton() { RadioButton rb = new RadioButton(); rb.AutoSize = true; rb.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); rb.Size = new System.Drawing.Size(335, 24); rb.TabStop = true; rb.UseVisualStyleBackColor = true; return rb; }Thanks again for your help :)