Click here to Skip to main content
15,902,189 members

Comments by dhaskins (Top 1 by date)

dhaskins 18-Oct-19 20:14pm View    
private void button1_Click(object sender, EventArgs e)
{
//The ComboBox is named comboBox1, and button1.Tag is set to comboBox1

Button aButton = (Button)sender;
string lastchar = aButton.Text.Substring(aButton.Text.Length - 1); //This returns 1 correctly

ComboBox cb = aButton.Tag as ComboBox; //No errors reported, but cb is always null

string cbName = "comboBox" + lastchar;

if (cb != null)
AddText(cbName, cb);
}

What am I missing here?