datetimeform.cs

来自「在CSharpNotepad中可以创建和编辑简单文本文档」· CS 代码 · 共 56 行

CS
56
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CSharpNotepad
{
    public partial class datetimeForm : Form
    {
        private mainForm _Owner;    //标记该子窗口的父窗口

        public datetimeForm()
        {
            InitializeComponent();
        }

        public datetimeForm(mainForm _Parent)
        {
            InitializeComponent();

            _Owner = _Parent;   //设置该子窗口的父窗口
        }


        private void datetimeForm_Load(object sender, EventArgs e)
        {
            listBox1.Items.Add(DateTime.Now.Date.ToShortDateString());
            listBox1.Items.Add(DateTime.Now.ToLongDateString());
            listBox1.Items.Add(DateTime.Now.ToLongTimeString());
            listBox1.Items.Add(DateTime.Now.DayOfWeek.ToString() + " " + DateTime.Now.ToLongDateString());
            listBox1.Items.Add(DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString());
            listBox1.Items.Add(DateTime.Now.ToString());
            listBox1.SelectedIndex = 0;
        }

        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            this._Owner.currentForm.richTextBox1.SelectedText = listBox1.SelectedItem.ToString();
            this.Close();
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            this._Owner.currentForm.richTextBox1.SelectedText = listBox1.SelectedItem.ToString();
            this.Close();
        }

        private void cancelButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?