I am just learning about classes and would like to know if this is the
correct use of class inheritence.
I have created a class called myFontBox as such:
public class myFontBox : ToolStripComboB ox
{
public myFontBox()
{
// Add the currently available font names to the combox box
foreach (FontFamily ff in System.Drawing. FontFamily.Fami lies)
if (ff.IsStyleAvai lable(FontStyle .Regular))
this.Items.Add( ff.Name);
}
}
This code is located in a file called CodeFile1.cs.
When I initialize it with:
myFontBox FontBox = new myFontBox();
toolStrip1.Item s.Add(FontBox);
everything works as it should. This code is located in a file called
Form1.cs. Both files are in the same namespace, Flash.
Now, here are my issues:
1) Is this a good use of class inheritence?
2) How do I handle events (such as when the user changes the selection)?
3) How do I initialize the FontBox.Text property? Although I know how to set
it to the desired setting, I do not know the best way to deliver it to the
class for processing. (I intend to base the initial selection on a textbox
located on the current form)
The first two are the ones I really need answers to, especially #2). The
last I may be able to figure out, once I know #2.
I appreciate any help possible.
correct use of class inheritence.
I have created a class called myFontBox as such:
public class myFontBox : ToolStripComboB ox
{
public myFontBox()
{
// Add the currently available font names to the combox box
foreach (FontFamily ff in System.Drawing. FontFamily.Fami lies)
if (ff.IsStyleAvai lable(FontStyle .Regular))
this.Items.Add( ff.Name);
}
}
This code is located in a file called CodeFile1.cs.
When I initialize it with:
myFontBox FontBox = new myFontBox();
toolStrip1.Item s.Add(FontBox);
everything works as it should. This code is located in a file called
Form1.cs. Both files are in the same namespace, Flash.
Now, here are my issues:
1) Is this a good use of class inheritence?
2) How do I handle events (such as when the user changes the selection)?
3) How do I initialize the FontBox.Text property? Although I know how to set
it to the desired setting, I do not know the best way to deliver it to the
class for processing. (I intend to base the initial selection on a textbox
located on the current form)
The first two are the ones I really need answers to, especially #2). The
last I may be able to figure out, once I know #2.
I appreciate any help possible.