Azurewrath

Hi,

Is it possible to have checked buttons, ie checkButtons

Thanks,

aw



Re: Windows Forms General Checked buttons?

Mattias Sjogren

Do you mean a CheckBox with its Appearance property set to Button






Re: Windows Forms General Checked buttons?

Jason Hale

You could toggle the text between an empty string and a check mark character (such as 0xFC with WingDings font) each time the button is pushed.





Re: Windows Forms General Checked buttons?

Azurewrath

Yes Mattias. Thanks Jason. Do you mean toggling a checkbox based on button clicks

Thanks again,

aw





Re: Windows Forms General Checked buttons?

Jason Hale

No, I meant to use a button and toggle the Text property on the button each time it is clicked.

It sounded like that's what you wanted - a button that could be checked or not.





Re: Windows Forms General Checked buttons?

Azurewrath

Thanks Jason. But I am not sure how to toggle the text property. Isn't it a string value

Thanks again,

aw





Re: Windows Forms General Checked buttons?

Gavin Jin - MSFT

Hi,do you mean to change the textbox property by a button or a checkbox




Re: Windows Forms General Checked buttons?

Azurewrath

Thanks for replying. I want a button like this (MAXScript button):

http://www.cgtechniques.com/images/ls_converter/overview_max.gif

Like a button, but functions like a checkbox.

Thanks,

aw





Re: Windows Forms General Checked buttons?

Amr Elsehemy

You can make your self a custom control that inherits from button and has a property named checked.

then handle the on click to toggle the state

public class ToggleButton: Button

{

private bool _checked;

public bool Checked

{

get { return _checked; }

set { _checked = value; }

}

public event EventHandler CheckedChanged;

protected override void OnClick(EventArgs e)

{

base.OnClick(e);

_checked = !_checked;

//change what ever u want for example backColor and FlatStyle

//or even raise an event

OnCheckChanged();

if (CheckedChanged != null)

{

CheckedChanged(this, EventArgs.Empty);

}

}

private void OnCheckChanged()

{

if (this.Checked)

{

this.FlatStyle = FlatStyle.Flat;

this.BackColor = Color.Yellow;

}

else

{

this.FlatStyle = FlatStyle.Standard;

this.BackColor = Color.Red;

}

}

}






Re: Windows Forms General Checked buttons?

Mattias Sjogren

Azurewrath wrote:

Like a button, but functions like a checkbox.

So why don't you just use the Checkbox control and change its Appearance property, like I told you in my first reply






Re: Windows Forms General Checked buttons?

Azurewrath

Thanks guys! Mattias, sorry I didn't get your first reply, but now when you told me this way, I tried it, and it's exactly what I wanted!

Thanks again,

aw