日期时间选择器控件的“焦点"属性? [英] The datetime picker control 'focused' property?

查看:200
本文介绍了日期时间选择器控件的“焦点"属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢您的回答..

我已经在自定义控件中使用datetime Picker来选择日期.为此,我使用了2个日期时间选择器.
使用事件值更改,我编写了代码.请阅读.

< code>私有无效dtp_ValueChanged(对象发送者,EventArgs e)
{
Control ctrl =(Control)sender;
if(ctrl.Focused)
{
StartDate = dtpStartDate.Value;
EndDate = dtpEndDate.Value;
SelectedDateRange = DateRange.Custom;
}
}</code>

Thanks for your answer..

I have used datetime Picker in a custom control for selecting dates. for which I have used 2 datetime pickers.
using the event valuechanged I wrote the code. please read it.

<code>private void dtp_ValueChanged(object sender, EventArgs e)
{
Control ctrl = (Control)sender;
if (ctrl.Focused)
{
StartDate = dtpStartDate.Value;
EndDate = dtpEndDate.Value;
SelectedDateRange = DateRange.Custom;
}
}</code>

推荐答案

检查该控件是否可聚焦.您可以检查属性CanFocus.现在,可以通过Tab导航将其聚焦(将属性TabStop设置为true).

我没有检查另一种可能性;你能做到吗?请改为检查ContainsFocus.如果ContainsFocus为true且IsFocused为false,则表示该控件是复合控件,因此只有其子控件中的一个获得焦点.对不起,我现在不能做.如果您在执行此操作时遇到问题,请提出问题并通过评论此答案通知我-我会进行检查并为您解释结果.

—SA
Check up it the control is focusable. You can check up the property CanFocus. Now, is it focusable by Tab navigation (set the property TabStop to true).

There is another possibility which I did not check up; could you do this? Check ContainsFocus instead. If ContainsFocus is true and IsFocused is false, it means that the control is composite so only one of its child control gets focus. Sorry I cannot do it right now. If you have a problem to do it, please ask a question and notify me by commenting this answer — I''ll check it up and explain the results for you.

—SA


因为Focus属性与选择的日期无关,所以它表示用户输入焦点"与选择日期有关.控制. IE.该用户输入将转到该控件,然后再转到其他控件.如果希望此控件具有输入焦点,请使用 Control.Focus [ ^ ]方法:
Because the Focus property does not have anything to do with the date being selected or not: It indicates that the "User Input Focus" is with the control. I.e. that user input will go to that control, and no other. If you want this control to have the input focus, use the Control.Focus[^] method:
myDateTimePicker.Focus();


这篇关于日期时间选择器控件的“焦点"属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆