none
when focus of control changes RRS feed

  • Question

  • I have two combo box which is custom type. In an open dialog screen 2 combo box are placed,by default first combo has set of values and combo 2 doesn't have data at all(disabled state in grey color).  if user clicks the C1 and select an item immediately C2 has enabled state if it has data otherwise disabled state. if user selects an item from c1 and focus goes to c2 and back to c1. in this case, user selects other item from c1 then c2 becomes disabled but white in color(should be grey in color)

     

    pls suggest an idea.

     

    Sunday, April 8, 2007 8:31 PM

Answers

  • Hi :

    so your logic is  c2 disable in two case:

                            1: no data for c2

                            2: c1 is focused

    am I right? you can see if follow code is you need

    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Text;

    using System.Windows.Forms;

     

    namespace Test

    {

        public partial class Form8 : Form

        {

            public Form8()

            {

                InitializeComponent();

            }

     

            private void Form8_Load(object sender, EventArgs e)

            {

                this.comboBox2.Enabled = false;

                this.comboBox1.Items.AddRange(new string[] { "c2 enable","c2 disable"});

                this.comboBox1.SelectedIndexChanged += new EventHandler(comboBox1_SelectedIndexChanged);

                this.comboBox1.Enter += new EventHandler(comboBox1_Enter);

            }

     

            void comboBox1_Enter(object sender, EventArgs e)

            {

                this.comboBox2.Enabled = false;

            }

     

            void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

            {

                if (this.comboBox1.SelectedItem.ToString() == "c2 enable")

                {

                    this.comboBox2.Items.Add("item");

                }

                else

                {

                    this.comboBox2.Items.Clear();

                }

                if (this.comboBox2.Items.Count != 0)

                { this.comboBox2.Enabled = true; }

            }

        }

    }

     

    Wednesday, April 18, 2007 11:29 AM

All replies

  •  Ganpp wrote:

    ..... in this case, user selects other item from c1 then c2 becomes disabled but white in color(should be grey in color)

     

    pls suggest an idea.

     

     

    hi Ganpp,

    If C2 is disabled ,it should be greyed.

     

    How are you ensuring that c2 becomes disabled(still white in color)?

     

    Thanks,

    Ch.T.Gopi Kumar.

    Monday, April 9, 2007 9:24 AM
  • C2 becomes disabled if data not found .
    Tuesday, April 17, 2007 6:25 PM
  • Hi :

    so your logic is  c2 disable in two case:

                            1: no data for c2

                            2: c1 is focused

    am I right? you can see if follow code is you need

    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Text;

    using System.Windows.Forms;

     

    namespace Test

    {

        public partial class Form8 : Form

        {

            public Form8()

            {

                InitializeComponent();

            }

     

            private void Form8_Load(object sender, EventArgs e)

            {

                this.comboBox2.Enabled = false;

                this.comboBox1.Items.AddRange(new string[] { "c2 enable","c2 disable"});

                this.comboBox1.SelectedIndexChanged += new EventHandler(comboBox1_SelectedIndexChanged);

                this.comboBox1.Enter += new EventHandler(comboBox1_Enter);

            }

     

            void comboBox1_Enter(object sender, EventArgs e)

            {

                this.comboBox2.Enabled = false;

            }

     

            void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

            {

                if (this.comboBox1.SelectedItem.ToString() == "c2 enable")

                {

                    this.comboBox2.Items.Add("item");

                }

                else

                {

                    this.comboBox2.Items.Clear();

                }

                if (this.comboBox2.Items.Count != 0)

                { this.comboBox2.Enabled = true; }

            }

        }

    }

     

    Wednesday, April 18, 2007 11:29 AM
  • Hi

    If you need , you can use this.ActiveControl to get current focused control on form

    Wednesday, April 18, 2007 11:36 AM
  • thanks for your effort. i got the answer too. iam working under the framework components so i need to change the customized combo box back color. that's it.
    Tuesday, April 24, 2007 10:36 PM