只能搞ReadOnly = true,除了光标的事儿搞不定,其它都好。
稍等。还有一个不好使的办法
- using System;
- using System.Runtime.InteropServices;
- using System.Windows.Forms;
- namespace WindowsFormsApp2
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- this.gcDateTime1.ReadOnly = true;
- }
- [DllImport("user32", EntryPoint = "HideCaret")]
- private static extern bool HideCaret(IntPtr hWnd);
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (this.gcDateTime1.Focused)
- {
- HideCaret(this.gcDateTime1.Handle);
- }
- }
- }
- }
-
- 一般情况下ReadOnly能满足他的需求,但是如果非要隐藏Caret的话,代码略微抽风一些。启动一个Timer硬搞。非常之不推荐。
复制代码 |