This is really frustrating me, I know it's something stupid that I missed. I have a combo box that loads all available fonts when the app starts up. When the user selects a font from the combo box, it should change the label to the font they selected. Here's what happens upon Initialization:

// load all available fonts into the combo box
            FontFamily[] ffArray = FontFamily.Families;
            foreach (FontFamily ff in ffArray)
            {
                if (ff.IsStyleAvailable(FontStyle.Regular))
                {
                    comboBox1.Items.Add(ff.Name);
                }
            }

And here's where I'm missing something; the combobox selected index changed event:

FontFamily[] ffArray = FontFamily.Families;
            foreach (comboBox1.SelectedIndex font in ffArray)
            {
                if (font.IsStyleAvailable(FontStyle.Regular))
                {
                    label1.Font = new Font(font, 14);
                }                
            }

Instead of comboBox1.SelectedIndex, try using comboBox1.SelectedItem

Instead of comboBox1.SelectedIndex, try using comboBox1.SelectedItem

I have already tried that.

Just use the following in your combo box selected index changed event handler

string font = comboBox1.SelectedItem.ToString();
            label3.Font = new System.Drawing.Font(font, 14);

I just tried that and it works.

Just use the following in your combo box selected index changed event handler

string font = comboBox1.SelectedItem.ToString();
            label3.Font = new System.Drawing.Font(font, 14);

I just tried that and it works.

Ahh simple and effective. Thanks :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.