Events and Callbacks
A feature that notifies developers of key lifecycle moments in the close button control, such as when a form is about to close, when animations complete, or when a close operation is undone, etc.
Overview
Events Summary
Event Name
Description
Triggering Action
Sample Usage Reference
Code Examples
Example 1: Handling BeforeFormClose Event
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using SiticoneNetFrameworkUI;
public class BeforeCloseDemoForm : Form
{
private SiticoneCloseButton closeButton;
public BeforeCloseDemoForm()
{
InitializeComponents();
}
private void InitializeComponents()
{
closeButton = new SiticoneCloseButton
{
Location = new Point(10, 10)
};
// Subscribe to the BeforeFormClose event
closeButton.BeforeFormClose += CloseButton_BeforeFormClose;
Controls.Add(closeButton);
Text = "BeforeFormClose Event Demo";
Size = new Size(300, 200);
}
private void CloseButton_BeforeFormClose(object sender, CancelEventArgs e)
{
// Prompt the user for confirmation before closing
var result = MessageBox.Show("Do you really want to close the form?", "Confirm Close",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result != DialogResult.Yes)
{
// Cancel the close operation if the user selects No
e.Cancel = true;
}
}
[STAThread]
public static void Main()
{
Application.EnableVisualStyles();
Application.Run(new BeforeCloseDemoForm());
}
}Example 2: Handling AnimationComplete Event
Example 3: Handling CloseUndone Event
Key Points
Aspect
Details
Best Practices
Recommendation
Explanation
Common Pitfalls
Pitfall
Description
Recommendation
Usage Scenarios
Scenario
Description
Code Sample Integration
Review
Review Point
Consideration
Summary
Additional Resources
Resource
Description
Link / Code Example Reference
Last updated