请选择 进入手机版 | 继续访问电脑版
 找回密码
 立即注册

QQ登录

只需一步,快速开始

liuwei19840201

中级会员

28

主题

67

帖子

504

积分

中级会员

积分
504

微信认证勋章

liuwei19840201
中级会员   /  发表于:2018-5-2 14:24  /   查看:3598  /  回复:3
本帖最后由 liuwei19840201 于 2018-5-7 09:15 编辑

版本 for winform 8.0
GcDate如何禁止输入,只能通过选择日历上的日期来改变值。
希望不要表示输入时的光标「|」。

3 个回复

倒序浏览
JeffryLI
葡萄城公司职员   /  发表于:2018-5-4 18:09:26
沙发
只能搞ReadOnly = true,除了光标的事儿搞不定,其它都好。
稍等。还有一个不好使的办法
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using System.Windows.Forms;
  4. namespace WindowsFormsApp2
  5. {
  6.     public partial class Form1 : Form
  7.     {
  8.         public Form1()
  9.         {
  10.             InitializeComponent();
  11.             this.gcDateTime1.ReadOnly = true;
  12.         }
  13.         [DllImport("user32", EntryPoint = "HideCaret")]
  14.         private static extern bool HideCaret(IntPtr hWnd);
  15.         private void timer1_Tick(object sender, EventArgs e)
  16.         {
  17.             if (this.gcDateTime1.Focused)
  18.             {
  19.                 HideCaret(this.gcDateTime1.Handle);
  20.             }
  21.         }
  22.     }
  23. }

  24. 一般情况下ReadOnly能满足他的需求,但是如果非要隐藏Caret的话,代码略微抽风一些。启动一个Timer硬搞。非常之不推荐。
复制代码
请点击评分,对我5分评价,谢谢!

葡萄城控件服务团队
官方网站: https://www.grapecity.com.cn/developer
回复 使用道具 举报
liuwei19840201
中级会员   /  发表于:2018-5-4 20:46:43
板凳
哎呀太感谢了,需要这这么多代码。
回复 使用道具 举报
JeffryLI
葡萄城公司职员   /  发表于:2018-5-7 12:04:32
地板
不客气
请点击评分,对我5分评价,谢谢!

葡萄城控件服务团队
官方网站: https://www.grapecity.com.cn/developer
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部