By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,667 Members | 1,863 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,667 IT Pros & Developers. It's quick & easy.

MyComboBox inherrited from ComboBox

P: n/a
Example:

public class MyComboBox : System.Windows.Forms.ComboBox;
{
public bool CanDropDown = true;

public MyComboBox()
{
}
}

Prease help me how modify this class for if CanDropDown = false, the user
can not open the drop down list of the combobox.
I do'nt want to use the Enabled propertie.

Thank you!
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
instead of using a public variable, use a public property

private book _canDropDown;

public bool CanDropDown
{
get
{
return _canDropDown;
}

set
{
// Set the internal value
_canDropDown = value;

// If the internal value if false, disable the dropdown
if (_canDropDown == false)
{
this.Enabled = false;
}
else
{
this.Enabled = true;
}
}
}

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Mihaly" <Mi****@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
Example:

public class MyComboBox : System.Windows.Forms.ComboBox;
{
public bool CanDropDown = true;

public MyComboBox()
{
}
}

Prease help me how modify this class for if CanDropDown = false, the user can not open the drop down list of the combobox.
I do'nt want to use the Enabled propertie.

Thank you!

Nov 16 '05 #2

P: n/a
I don't want to use the Enabled property. I want to let Enabled = true,
but to denide drop down the combobox's dropdown list.
I tried to override OnDropDown() protected methode, but it's not working.

Example:

protected override void OnDropDown()
{
if (this.CanDropDown)
base.OnDropDown();
}

Thank you!

"Manohar Kamath" wrote:
instead of using a public variable, use a public property

private book _canDropDown;

public bool CanDropDown
{
get
{
return _canDropDown;
}

set
{
// Set the internal value
_canDropDown = value;

// If the internal value if false, disable the dropdown
if (_canDropDown == false)
{
this.Enabled = false;
}
else
{
this.Enabled = true;
}
}
}

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Mihaly" <Mi****@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
Example:

public class MyComboBox : System.Windows.Forms.ComboBox;
{
public bool CanDropDown = true;

public MyComboBox()
{
}
}

Prease help me how modify this class for if CanDropDown = false, the

user
can not open the drop down list of the combobox.
I do'nt want to use the Enabled propertie.

Thank you!


Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.