Exemple #1
0
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose(bool disposing)
		{
			Debug.WriteLineIf(!disposing, "****************** Missing Dispose() call for " + GetType().Name + " ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			// m_sda COM object block removed due to crash in Finializer thread LT-6124

			if (disposing)
			{
				if (m_button != null)
				{
					m_button.MouseDown -= m_button_MouseDown;
					m_button.KeyDown -= m_button_KeyDown;
					m_button.GotFocus -= m_button_GotFocus;
					m_button.LostFocus -= m_button_LostFocus;
				}

				if (m_sda != null)
					m_sda.RemoveNotification(this);

				if (m_comboTextBox != null)
				{
					m_comboTextBox.KeyDown -= m_comboTextBox_KeyDown;
					m_comboTextBox.MouseDown -= m_comboTextBox_MouseDown;
					m_comboTextBox.GotFocus -= m_comboTextBox_GotFocus;
					m_comboTextBox.LostFocus -= m_comboTextBox_LostFocus;
				}

				if (m_dropDownBox != null && !m_dropDownBox.IsDisposed)
				{
					m_dropDownBox.Form.VisibleChanged -= Form_VisibleChanged;
					m_dropDownBox.Dispose();
				}
			}
			m_sda = null;
			m_button = null;
			m_comboTextBox = null;
			m_dropDownBox = null;

			base.Dispose(disposing);
		}
Exemple #2
0
		/// <summary>
		/// Construct one.
		/// </summary>
		public FwComboBoxBase()
		{
			if (Application.RenderWithVisualStyles)
				DoubleBuffered = true;

			SuspendLayout();
			// Set this box's own properties (first, as we use some of them in figuring the
			// size of other things).

			// Make and install the ComboTextBox
			m_comboTextBox = new ComboTextBox(this);
			m_comboTextBox.AccessibleName = "TextBox";
			m_comboTextBox.Dock = DockStyle.Fill;
			m_comboTextBox.Visible = true;

			// This causes us to get a notification when the string gets changed, so we can fire our
			// TextChanged event.
			m_sda = m_comboTextBox.DataAccess;
			m_sda.AddNotification(this);

			m_comboTextBox.KeyDown += m_comboTextBox_KeyDown;
			m_comboTextBox.MouseDown += m_comboTextBox_MouseDown;
			m_comboTextBox.GotFocus += m_comboTextBox_GotFocus;
			m_comboTextBox.LostFocus += m_comboTextBox_LostFocus;
			m_comboTextBox.TabIndex = 1;
			m_comboTextBox.TabStop = true;

			m_textBoxPanel = new Panel();
			m_textBoxPanel.AccessibleName = "TextBoxPanel";
			m_textBoxPanel.Dock = DockStyle.Fill;
			m_textBoxPanel.BackColor = Color.Transparent;
			m_textBoxPanel.Controls.Add(m_comboTextBox);
			Controls.Add(m_textBoxPanel);

			// Make and install the button that pops up the list.
			m_button = new DropDownButton(this);
			m_button.AccessibleName = "DropDownButton";
			m_button.Dock = DockStyle.Right; // Enhance JohnT: Left if RTL language?
			m_button.TabStop = false;

			//m_button.FlatStyle = FlatStyle.Flat; // no raised edges etc for this button.
			////			m_button.Click += new EventHandler(m_button_Click);

			m_button.MouseDown += m_button_MouseDown;
			m_button.KeyDown += m_button_KeyDown;
			m_button.GotFocus += m_button_GotFocus;
			m_button.LostFocus += m_button_LostFocus;

			m_buttonPanel = new Panel();
			m_buttonPanel.AccessibleName = "DropDownButtonPanel";
			m_buttonPanel.Dock = DockStyle.Right;
			m_buttonPanel.BackColor = Color.Transparent;
			m_buttonPanel.Controls.Add(m_button);
			Controls.Add(m_buttonPanel);

			HasBorder = true;
			Padding = new Padding(Application.RenderWithVisualStyles ? 2 : 1);
			base.BackColor = SystemColors.Window;

			m_buttonPanel.Width = m_button.PreferredWidth + m_buttonPanel.Padding.Horizontal;

			m_dropDownBox = CreateDropDownBox();
			m_dropDownBox.Form.VisibleChanged += Form_VisibleChanged;

			ResumeLayout();
		}