[C#] MenuStrip, SaveFileDialog, OpenFileDialog, PcitureBox, Class Library (.NET Framework) + Custom Control
2021. 10. 16. 10:48ㆍProgramming/C#
1. MenuStrip
- Shortcut using Alt: “&Save” = Save (Alt + S) → Navigating with keyboard
- Shortcut using Ctrl: ShortcutKeys Property
2. SaveFileDialog
- OpenDialogbox, SaveDialogBox just pass file path
- FileFormat is important! è filename always include Filepath
- Always surround dialog with try-catch
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
DialogResult dialogResult = dlgSave.ShowDialog();
switch (dialogResult)
{
case DialogResult.None:
break;
case DialogResult.OK:
try
{
string fileName = dlgSave.FileName;
int numberOfItems = int.Parse(txtNumverOfItems.Text);
// MessageBox.Show(fileName);
save(fileName, numberOfItems);
}
catch (Exception ex)
{
MessageBox.Show("Error in file save");
}
break;
case DialogResult.Cancel:
break;
case DialogResult.Abort:
break;
case DialogResult.Retry:
break;
case DialogResult.Ignore:
break;
case DialogResult.Yes:
break;
case DialogResult.No:
break;
default:
break;
}
}
3. OpenFileDialog
- dilogOpen.SafeFileName Property
- InitialDirectory
- Filter Property: “|” separator, *.* technical
4. PictureBox
- Load image
- Image.FromFile(fileName)
- Bitmap class => child of Image class
5. Class Library (.NET Framework) = dll file
- Class Library Project doesn’t have program.cs è Not Executable by itself
- If we build the class library project, it will generate dll file
- Enum : 1. make code readable 2. make dropdown in property!!
- Auto-implemented getter, but a custom setter? No. You can either define both getter and setter, or have the C# compiler generate both of them for you," https://codeasy.net/lesson/properties
Learn C# Properties: Getters and Setters at Intermediate C# Course
Loneliness If I had a chance to talk with a psychotherapist, I would say that I was tired of being alone in the future; tired of fighting dozens of robots to save a humanity to which I didn't belong. She might look at me with penetrating eyes and ask, "Why
codeasy.net
6. New project in Class Library
- Bold Project = starter project (Set as a startup Project)
- If you don’t see WorldClock in Windows form tool box, you can rebuild it.
- You can retrieve the property that you created!
- User Control Property Visibliity: [Browsable(true/false)]
- User Control Property description: [Description]
- User Control Property Category: [Category]
7. How to add user control in one solution file
- Add user control like you are adding a class
Tip.
Cw tab tab
Mbox tab tab
'Programming > C#' 카테고리의 다른 글
[C#] Import dll file in client side, Interface (0) | 2021.10.18 |
---|---|
[C#] Inheritance, Polymorphism, Abstraction (0) | 2021.10.08 |
[C#] Inheritance, Object-Oriented-Programming, Polymorphism (0) | 2021.10.03 |
[C#] Collection, Inheritance (Feat. base keyword) (0) | 2021.10.02 |