-
空调控制源代码
空调控制源代码,在这里贡献给大家研究
- 2023-02-04 07:30:04下载
- 积分:1
-
C# 设置应用程序背景颜色
C# 设置应用程序背景颜色,通过调用Windows调色板,来选取颜色,然后程序将颜色值赋值给窗口,此盒子可设置斜体的颜色值,运行效果如参考截图所示,核心代码请看以下代码片段:
private void Form1_Load(object sender, EventArgs e)
{//显示应用程序背景颜色
//先打开“Properties”,添加一个System.Drawing.Color类型的变量MyBackColor
this.BackColor = Properties.Settings.Default.MyBackColor;
}
private void button1_Click(object sender, EventArgs e)
{//设置应用程序背景颜色(在运行时编写用户设置)
if(this.colorDialog1.ShowDialog()==DialogResult.OK)
{
Properties.Settings.Default.MyBackColor = this.colorDialog1.Color;
Properties.Settings.Default.Save();
this.BackColor = Properties.Settings.Default.MyBackColor;
}
}
- 2022-06-22 05:36:16下载
- 积分:1
-
C# 从RichTextBox 控件中提取文本内容
C# 从RichTextBox 控件中提取文本内容,并设置RichTextBox 控件中的字体大小-附完整源代码,
private void button1_Click(object sender, RoutedEventArgs e)
{//从RichTextBox 控件中提取文本内容
TextRange MyText = new TextRange(this.richTextBox1.Document.ContentStart, this.richTextBox1.Document.ContentEnd);
MessageBox.Show(MyText.Text, "RichTextBox控件中的文本内容",MessageBoxButton.OK);
}
private void button2_Click(object sender, RoutedEventArgs e)
{//设置RichTextBox 控件中的字体大小
TextRange MyText = new TextRange(this.richTextBox1.Document.ContentStart, this.richTextBox1.Document.ContentEnd);
MyText.ApplyPropertyValue(TextElement.FontSizeProperty, 36.00);
MyText.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
- 2022-09-21 17:55:02下载
- 积分:1
-
C# 启动和关闭无窗体定时器
C# 启动和关闭无窗体定时器,单击窗体上对应的按钮,即可完成无窗体定时器的启动和关闭功能,核心代码为:
private void button1_Click(object sender, EventArgs e)
{//启动无窗体定时器
var MyClass = new MyThreadClass();
MyTimer = new System.Threading.Timer(MyClass.MyCallBackMethod, MyClass, 5000, 2000);
}
private void button2_Click(object sender, EventArgs e)
{//关闭无窗体定时器
MyTimer.Dispose();
}
- 2022-04-09 03:53:39下载
- 积分:1
-
C# 热键模拟 模拟数字输入、英文输入Home键、Backspace键
C#通过窗体的按钮来模拟按下键盘上指定键的功能,比如模拟出了Shift+Home、Delete、Enter、Home、Backspace、数字输入、英文输入等键的功能,相关功能模块代码如下,可自己添加相关的模块功能键:
private void button3_Click(object sender, System.EventArgs e)
{//Backspace空格键
this.richTextBox1.Focus();
SendKeys.Send("{Backspace}");
}
private void button4_Click(object sender, System.EventArgs e)
{ //End结束键
this.richTextBox1.Focus();
SendKeys.Send("{End}");
}
private void button5_Click(object sender, System.EventArgs e)
{//Home键
this.richTextBox1.Focus();
SendKeys.Send("{Home}");
}
private void button6_Click(object sender, System.EventArgs e)
{//Enter回车键
this.richTextBox1.Focus();
SendKeys.Send("{Enter}");
}
private void button7_Click(object sender, System.EventArgs e)
{//Delete删除键
this.richTextBox1.Focus();
SendKeys.Send("{Delete}");
}
- 2022-07-19 00:15:03下载
- 积分:1
-
Visual C# WPF 实现文字左右流动(滚动)效果
Visual C# WPF技术实现文字内容从左向右流动、从右向左流动,其实就是文字滚动,稍加了一些特殊处理,下面来看看代码真的好简单:
private void button1_Click(object sender, RoutedEventArgs e)
{//内容从左向右流动
this.MyFlowDocument.FlowDirection = FlowDirection.LeftToRight;
}
private void button2_Click(object sender, RoutedEventArgs e)
{//内容从右向左流动
this.MyFlowDocument.FlowDirection = FlowDirection.RightToLeft;
}
- 2022-02-04 14:45:10下载
- 积分:1
-
C# 清除IE地址栏中的历史网址(修改注册表)
C# 清除IE地址栏中的历史网址,也就是历史记录,这些记录都是平时自己输入的,IE会自动保存,本程序会把保存的这些网址信息全部删除了,主要是删除注册表中对应键值下的URL子键:
RegistryKey rkBase = Registry.CurrentUser;//定位到CurrentUser注册表项
//打开指定的注册表项
RegistryKey rkChild = rkBase.OpenSubKey(@"SoftwareMicrosoftInternet ExplorerTypedURLs",true);
String[] strValueNames = rkChild.GetValueNames();//获取所有的历史网址
foreach (string strItem in strValueNames)//遍历获取到的历史网址
{
rkChild.DeleteValue(strItem);//删除遍历到的历史网址
}
- 2022-11-06 13:05:04下载
- 积分:1
-
C# 判断计算机中是否安装了SQLServer软件
C# 判断计算机中是否安装了SQLServer软件,那么是如何判断这个呢?主要是判断是还存在SQL服务,获取Windows服务控制器中的内容,然后过滤字符串"MSSQLSERVER",返回的布尔值若为真,则说明电脑中安装有SQLServer软件。然后在WinForm窗口中使用 label1.Text = "本地计算机中已经安装SQL软件";显示字符串提示信息,简单吧?
- 2022-04-25 11:08:17下载
- 积分:1
-
Visual C#对 XML操作的演示示例集
这是一个C#操作XML文件的示例集,可完成 如下功能演示:
枚举XML集合中的元素名称
枚举XML集合中的元素文本
判断XML元素在集合中是否存在
筛选XML中的子代元素集合
使用链接轴方法枚举XML元素
根据元素属性查找XML元素
根据元素名称查找XML元素
根据元素属性和名称查找XML元素
根据中间计算值查找XML元素
比如枚举XML集合中的元素文本:private void button2_Click(object sender, EventArgs e)
{//枚举XML集合中的元素文本
XElement MyXElements = new XElement("Root",
new XElement("贵州省", "贵阳市"),
new XElement("四川省", "成都市"));
IEnumerable MyXElement =
from MySelect in MyXElements.Elements()
select MySelect;
string MyInfo = "元素文本包括:";
foreach (XElement MyValue in MyXElement)
MyInfo += MyValue.Value + "、";
//显示:贵阳市、成都市
MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK);
}
- 2022-03-14 22:11:51下载
- 积分:1
-
C# SelectionStart SelectionEnd时间段选择日历范例
C# Calendar 时间段选择日历范例,可选择时间区间,调用 了C#中的SelectionStart SelectionEnd日期函数实现的功能,这个程序演示了两种功能:
1、获取控件当前的日期和时间
textBox1.Text = monthCalendar1.TodayDate.ToString();
2、时间起始段的选择:
通过SelectionStart属性获取用户选择的起始日期
textBox2.Text = monthCalendar1.SelectionStart.ToString();
通过SelectionEnd属性获取用户选择的结束日期
textBox3.Text = monthCalendar1.SelectionEnd.ToString();
- 2022-08-15 10:37:28下载
- 积分:1