473,769 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MonthCalendar on another form

Hi there,

I have a WindowsForm which includes a label. I want to add a date to
this label which a user can select.

I thought it is probably the best to open another WindowsForm and to
add on this one a monthcalendar.

My prolbem is: How can I use this MonthcalendarFo rm to edit / add the
date of the label on other forms.
(It should be possible to use this monthcalendarfo rm for diffrent
forms)

Hope you can understand my problem!

Thank you very much in advance for your help.

Kind regards,

SePp
Feb 28 '08 #1
2 2732
Hi SePp,

The MonthCalendar form needs to know the date by receiving it in its
constructor or by exposing a public property the parent form can set before
displaying the MonthCalendar form. When the form closes, the parent can read
a property on the MonthCalendar form to find out which value the user
selected. Typically the code would like something like the below (will
probably need correction to work)

// Parent form

public void button1_Click(o bject sender, EventArgs e)
{
DateTime date = DateTime.Parse( label1.Text);

MonthCalendarFo rm mcFom = new MonthCalendarFo rm();
form.Date = date;

if(form.ShowDia log() == DialogResult.OK )
{
label1.Text = form.Date.ToStr ing();
}
}

// MonthCalendarFo rm

private DateTime _date

public DateTime Date
{
get{ return _date;}
set{ _date = value;}
}

protected override void OnLoad(EventArg s e)
{
monthCalendar1. Date = Date;
}

public void button1_Click(o bject sender, EventArgs e)
{
Date = monthCalendar1. Date;
DialogResult = DialogResult.OK ;
Close();
}

--
Happy Coding!
Morten Wennevik [C# MVP]
"SePp" wrote:
Hi there,

I have a WindowsForm which includes a label. I want to add a date to
this label which a user can select.

I thought it is probably the best to open another WindowsForm and to
add on this one a monthcalendar.

My prolbem is: How can I use this MonthcalendarFo rm to edit / add the
date of the label on other forms.
(It should be possible to use this monthcalendarfo rm for diffrent
forms)

Hope you can understand my problem!

Thank you very much in advance for your help.

Kind regards,

SePp
Feb 28 '08 #2
On Feb 28, 2:29 pm, Morten Wennevik [C# MVP]
<MortenWenne... @hotmail.comwro te:
Hi SePp,

The MonthCalendar form needs to know the date by receiving it in its
constructor or by exposing a public property the parent form can set before
displaying the MonthCalendar form. When the form closes, the parent can read
a property on the MonthCalendar form to find out which value the user
selected. Typically the code would like something like the below (will
probably need correction to work)

// Parent form

public void button1_Click(o bject sender, EventArgs e)
{
DateTime date = DateTime.Parse( label1.Text);

MonthCalendarFo rm mcFom = new MonthCalendarFo rm();
form.Date = date;

if(form.ShowDia log() == DialogResult.OK )
{
label1.Text = form.Date.ToStr ing();
}

}

// MonthCalendarFo rm

private DateTime _date

public DateTime Date
{
get{ return _date;}
set{ _date = value;}

}

protected override void OnLoad(EventArg s e)
{
monthCalendar1. Date = Date;

}

public void button1_Click(o bject sender, EventArgs e)
{
Date = monthCalendar1. Date;
DialogResult = DialogResult.OK ;
Close();

}

--
Happy Coding!
Morten Wennevik [C# MVP]

"SePp" wrote:
Hi there,
I have a WindowsForm which includes a label. I want to add a date to
this label which a user can select.
I thought it is probably the best to open another WindowsForm and to
add on this one a monthcalendar.
My prolbem is: How can I use this MonthcalendarFo rm to edit / add the
date of the label on other forms.
(It should be possible to use this monthcalendarfo rm for diffrent
forms)
Hope you can understand my problem!
Thank you very much in advance for your help.
Kind regards,
SePp
Hi Morten,

Thank you very much for helping!

Greets
SePp
Feb 28 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2227
by: anthonytjea | last post by:
Hi all, Iam trying to embed the well known Month Calendar found at http://www.lebans.com/monthcalendar.htm directly into an MS Access form the same way that the ActiveX Calendar Control is embedded into the form (ie. I want the MonthCalendar to be part of the form instead of popping up in a seperate window). Thanks
3
14262
by: michael_hk | last post by:
Hi, I am new to Windows Form programming and now have a simple Q about MonthCalendar. I want to hightlight some days in the calendar by changing the background color of these days. But I can't find any property or method that let me do this. What I know is that I can bold them... Thanks.
2
1201
by: Steven | last post by:
Hello, I have an application with multiple forms. One of the forms contains a monthcalendar. Each 2 minutes, the monthcalendar is getting the focus. I don't know why, it seems like this happens automatically. This is pretty annoying, because if another form was opened, the whole form with the monthcalendar appears on top of the opened form (which had the focus).
13
3676
by: steven | last post by:
A monthcalendar checks every 2 minutes if theres a new day. Does anyone knows how to disable this ? The problem is that, everytime a monthcalendar checks this, the form where the monhcalendar is on, gets the focus, which is VERY annoying. Thanks, Steven
0
1373
by: steven | last post by:
Start a new project with 2 forms: one with a datagrid, a button and a monthcalendar, and another form without controls. Try this code in your form with the monthcalendar: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim frm As Form frm = New Form2 frm.Show()
8
2619
by: vbmark | last post by:
I want the MonthCalendar control to return the single day selected. I have MaxSelectionCount = 1. What I get back though is this: "SelectionRange: Start: 5/5/2005 12:00:00 AM, End: 5/5/2005 12:00:00 AM" How do I get the single day date?
3
11008
by: RG | last post by:
For a Windows project in VB.NET 2003: I need a Calendar that’s much larger than the MonthCalendar control in the toolbox; it needs to fill the whole screen (at least approximately ). VB won’t allow me to change the Size Height or Width Properties. I see that you can size a Calendar control in a Web project all you like; but I’m creating a Windows application project here. I see that Size comes from System.Drawing.Size...
1
3529
by: DS | last post by:
I seem to have run into another strange anomaly with the monthCalendar control. I want to display 6 months at time with either the first half of the year (January-June) or the later half of the year (July-Dec) being rendered- depending on where todays date falls. I also want today's date to be selected. This poses a problem. Refer to the code below. Add a call to createCalendar() to your constructor (AFTER the InitializeComponents()...
11
7389
by: Randy | last post by:
I have a MonthCalendar on one of my forms. I have disovered that the DateChanged event is triggered not only when the user clicks on a new date, but also if they click on the Previous or Next Month arrows (meaning they click on either of the left or right pointing arrows in the top corner). If the user changes the month, it messes up some of the date logic that I have in the DateChanged event. Does anybody know how I can capture this...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10212
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10047
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.