I tried an implementation of this idea but it never fires. Am I correctly
implementing this? Or are the overrides wrong?
Please help.
Thanks,
Ron
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Collections;
using System.Drawing.Drawing2D;
namespace GeneralTesting
{
public partial class frmMain : Form
{
MyCustomComboBox TB1 = new MyCustomComboBox();
public frmMain()
{
InitializeComponent();
TB1.FormattingEnabled = true;
TB1.Location = new System.Drawing.Point(13, 214);
TB1.Name = "TB1";
TB1.Size = new System.Drawing.Size(385, 21);
TB1.TabIndex = 1;
TB1.SelectedIndexChanged += new
System.EventHandler(this.TB1_SelectedIndexChanged_1);
this.Controls.Add(TB1);
DataClass DC = new
}
private void TB1_SelectedIndexChanged_1(object sender, EventArgs e)
{
richTextBox1.Text += ((Employee)TB1.SelectedItem).ToString() + "\n";
TB1.Items.Remove((Employee)TB1.SelectedItem);
}
private void button1_Click(object sender, EventArgs e)
{
if (TB1.Enabled == true)
{
TB1.Enabled = false;
}
else
{
TB1.Enabled = true;
}
}
class MyCustomComboBox : ComboBox
{
protected override void OnPaint(PaintEventArgs e)
{
// ...
MessageBox.Show("TRIGGERED OnPaint");
}
protected override void OnPaintBackground(PaintEventArgs e)
{
// .. I suspect you may be more interested in
// .. override its background painting.
MessageBox.Show("TRIGGERED OnPaintBackground");
}
}
}
}