ComboBox.BackColor when ComboBox.Enabled = false;

  • Thread starter Thread starter Broeden
  • Start date Start date
B

Broeden

Hi,

I need to inherit from av Combobox component and override a suitable
method to set the backcolor to white when the control is disabled. I
need the text to more readable in daylight.

In the full framework I can override WndProc(ref Message m), but in CF
this is not possible. Does anybody know how to do i?

/Broeden
 
Mistake by me. It's the Font Color I want to set i CF2.0. In .NET
Framework I needed to set the BackColor to get the same effect. But
principally the problem is the same I think.
/Broeden
 
Mistake by me. It's the Font Color I want to set i CF2.0. In .NET
Framework I needed to set the BackColor to get the same effect. But
principally the problem is the same I think.
/Broeden

Hi,

You can achieve read only effect with your own formatting on control.
Don't disable the combo box. Change the fore color to what ever you
want.
Move the focus to any other control on the form on get focus event of
combo box.
public Form1()
{
InitializeComponent();
comboBox1.Enabled = true;
comboBox1.ForeColor = Color.Blue;
comboBox1.SelectedIndex = 0;
}

private void comboBox1_GotFocus(object sender, EventArgs e)
{
textBox1.Focus();
}

Thanks,
Jayesh Modha
 
Thanks Jayesh!

I have suspected there must be a simple solution. This seems to be the
one.

ComboBoxes and TextBoxes works OK. But it's not working on
numericUpDown controls. I can still increase and decrease the value.

/Broeden
 
Thanks Jayesh!

I have suspected there must be a simple solution. This seems to be the
one.

ComboBoxes and TextBoxes works OK. But it's not working on
numericUpDown controls. I can still increase and decrease the value.

/Broeden

Hi,

With numericUpDown, It might be more easy.
I just tried to set increment property to zero 0.
It has given the desired result.
this.numericUpDown1.Increment = new decimal(new int[] {0,0,0,0});
Try this, let's see if this works out.

Thanks,
Jayesh Modha
 
Thanks again,

I got the desired behavior by setting Minimum and Maximum to Value.
But your solution is a bit simpler because I don't have to keep track
on different Min/Max for each control.

/Broeden
 
Back
Top