Skip to content

Commit 5c573ea

Browse files
authored
Merge pull request #4 from SyncfusionExamples/985360
985360: Updated ReadMe file
2 parents 5130370 + 66f3249 commit 5c573ea

File tree

1 file changed

+57
-2
lines changed

1 file changed

+57
-2
lines changed

README.md

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,57 @@
1-
# How-to-create-a-DatePicker-in-Winforms-using-ButtonEdit-and-MonthCalendarAdv
2-
This session describes how to create a DatePicker in Winforms using ButtonEdit and MonthCalendarAdv
1+
# How to Create a DatePicker in WinForms Using ButtonEdit and MonthCalendarAdv
2+
This example demonstrates how to create a DatePicker in a WinForms application using Syncfusion’s ButtonEdit and MonthCalendarAdv controls. Combining these controls provides a user-friendly date selection interface that integrates seamlessly into Windows Forms applications.
3+
4+
## Why This Is Useful
5+
- Customizable UI: Offers flexibility compared to standard DatePicker controls.
6+
- Rich Calendar Features: MonthCalendarAdv supports advanced customization.
7+
- Better UX: Provides an intuitive way for users to select dates.
8+
9+
## How It Works
10+
- The ButtonEdit control acts as a container with a clickable button.
11+
- When the button is clicked, a popup containing the MonthCalendarAdv control is displayed.
12+
- The selected date from the calendar updates the ButtonEdit text box.
13+
14+
## Key Implementation Steps
15+
- Initialize the MonthCalendarAdv control.
16+
- Add the calendar to a popup container.
17+
- Attach the popup to the ButtonEdit control.
18+
- Handle the DateSelected event to update the text box with the selected date.
19+
- Toggle the visibility of the calendar popup when the button is clicked.
20+
21+
## Sample Code
22+
```C#
23+
MonthCalendarAdv monthCalendarAdv = new MonthCalendarAdv();
24+
25+
public Form1()
26+
{
27+
InitializeComponent();
28+
29+
// Attach event handler for button click
30+
childButton.Click += ChildButton_Click;
31+
32+
// Add calendar to popup and configure layout
33+
calendarPopup.Controls.Add(monthCalendarAdv);
34+
buttonEdit1.Buttons.Add(childButton);
35+
tableLayoutPanel1.Controls.Add(calendarPopup, 0, 1);
36+
37+
// Handle date selection
38+
monthCalendarAdv.DateSelected += MonthCalendarAdv_DateSelected;
39+
}
40+
41+
private void MonthCalendarAdv_DateSelected(object sender, EventArgs e)
42+
{
43+
// Update ButtonEdit text with selected date
44+
buttonEdit1.TextBox.Text = monthCalendarAdv.Value.ToString();
45+
calendarPopup.Visible = false;
46+
}
47+
48+
private void ChildButton_Click(object sender, EventArgs e)
49+
{
50+
// Show calendar popup
51+
calendarPopup.Visible = true;
52+
}
53+
```
54+
55+
## Output
56+
57+
![DatePicker](ChildButtonClick_ButtonEdit/Images/DatePicker.png).

0 commit comments

Comments
 (0)