由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
DotNet版 - How to cancel DateTimePicker event?
相关主题
问题又来了.那个Control可以做这个事情?
CrystalReport 问题File.Copy怎么老是出错?
我不知道.net里大家什么用得做多webbrowser control question
Windows, freeBSD, Mac OS X support CLIWhat is SmartClient?
screebshot: winform based weather app[合集] 我不知道.net里大家什么用得做多
About memory usage of .Net program[合集] webbrowser control question
About monowinform显示excel文件的问题
Winform Question.Please help.觉得C#的valuetype和boxing真的是没有必要
相关话题的讨论汇总
话题: dt2话题: dt1话题: eventargs
进入DotNet版参与讨论
1 (共1页)
c**t
发帖数: 2744
1
There are two dateTimePickers on a winform, which requires dt2 > dt1;
if dt1 is picked greater than dt2, reset dt1 to dt2-1; but the messagebox
pops
out twice. How to disable the second one? ..EnableEvents seems not working
//The code is as follows.
private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
{
if (this.dateTimePicker1.Value > this.dateTimePicker2.Value)
{
MessageBox.Show("This date should NOT be earlier then " +
this.dateTimeP
k****i
发帖数: 1072
2
Per your description, the code should be changed as follows:
private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
{
if (this.dateTimePicker1.Value > this.dateTimePicker2.Value)
{
MessageBox.Show("This date should NOT be earlier then " +
this.dateTimePicker1.Value.ToShortDateString() + "!");
this.Application.EnableEvents = false;
this.dateTimePicker1.Value = this.dateTimePicker2.Value.
AddDays(-1);


【在 c**t 的大作中提到】
: There are two dateTimePickers on a winform, which requires dt2 > dt1;
: if dt1 is picked greater than dt2, reset dt1 to dt2-1; but the messagebox
: pops
: out twice. How to disable the second one? ..EnableEvents seems not working
: //The code is as follows.
: private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
: {
: if (this.dateTimePicker1.Value > this.dateTimePicker2.Value)
: {
: MessageBox.Show("This date should NOT be earlier then " +

c**t
发帖数: 2744
3
the messagebox is still called twice.
I tried both:
this.Application.EnableEvents = false;
this.dateTimePicker1.Value = this.dataTimePicker2.Value.AddDays(-1);
this.Application.EnableEvents = true;
and
Globals.ThisWorkbook.Application.EnableEvents = false;
..
Globals.ThisWorkbook.Applicaiton.EnableEvents = true;
Neither worked.

【在 k****i 的大作中提到】
: Per your description, the code should be changed as follows:
: private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
: {
: if (this.dateTimePicker1.Value > this.dateTimePicker2.Value)
: {
: MessageBox.Show("This date should NOT be earlier then " +
: this.dateTimePicker1.Value.ToShortDateString() + "!");
: this.Application.EnableEvents = false;
: this.dateTimePicker1.Value = this.dateTimePicker2.Value.
: AddDays(-1);

c**t
发帖数: 2744
4
I used a static counter, and confirmed that the popup was called twice

【在 k****i 的大作中提到】
: Per your description, the code should be changed as follows:
: private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
: {
: if (this.dateTimePicker1.Value > this.dateTimePicker2.Value)
: {
: MessageBox.Show("This date should NOT be earlier then " +
: this.dateTimePicker1.Value.ToShortDateString() + "!");
: this.Application.EnableEvents = false;
: this.dateTimePicker1.Value = this.dateTimePicker2.Value.
: AddDays(-1);

k****i
发帖数: 1072
5
Does the dateTimePicker1.Value change between these two calls?

【在 c**t 的大作中提到】
: I used a static counter, and confirmed that the popup was called twice
c**t
发帖数: 2744
6
obviously!

【在 k****i 的大作中提到】
: Does the dateTimePicker1.Value change between these two calls?
c**t
发帖数: 2744
7
found solution!
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
this.dateTimePicker1.MaxDate = this.dateTimePicker2.Value;
..
}
private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
{
this.dateTimePicker2.MinDate = this.dateTimePicker1.Value;
..
}

working

【在 c**t 的大作中提到】
: There are two dateTimePickers on a winform, which requires dt2 > dt1;
: if dt1 is picked greater than dt2, reset dt1 to dt2-1; but the messagebox
: pops
: out twice. How to disable the second one? ..EnableEvents seems not working
: //The code is as follows.
: private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
: {
: if (this.dateTimePicker1.Value > this.dateTimePicker2.Value)
: {
: MessageBox.Show("This date should NOT be earlier then " +

1 (共1页)
进入DotNet版参与讨论
相关主题
觉得C#的valuetype和boxing真的是没有必要screebshot: winform based weather app
C#的new在method declaration里有和没有有啥区别么About memory usage of .Net program
Demos from MIX08About mono
Looking for .Net winform developer with oralce backgroundWinform Question.Please help.
问题又来了.那个Control可以做这个事情?
CrystalReport 问题File.Copy怎么老是出错?
我不知道.net里大家什么用得做多webbrowser control question
Windows, freeBSD, Mac OS X support CLIWhat is SmartClient?
相关话题的讨论汇总
话题: dt2话题: dt1话题: eventargs