-
vb串口调试助手源码,可用于自己做调试测试工具
1.用易懂的VB语言编程 2.可设置串口号波特率 3.支持十六进或字符形式发送或接收,可定时发送。3,可自己换程序的图片
- 2022-07-13 02:02:52下载
- 积分: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# 使用Graphics对象在程序运行时创建位图
C# 在程序运行时创建位图,本源码实例主要是学习使用使用Graphics对象创建简单图像的例子,本程序将生成一条曲线图像,参照如下代码:
{//在程序运行时创建位图
int MyWidth=this.pictureBox1.Width;
int MyHeight=this.pictureBox1.Height;
Bitmap MyBitmap = new Bitmap(MyWidth,MyHeight);
Graphics MyGraphics = Graphics.FromImage(MyBitmap);
Pen MyPen = new Pen(Color.Black, 3);
Point[] MyPoints = { new Point(50, 100), new Point(100, 10), new Point(150, 290), new Point(200, 100), new Point(250, 10), new Point(300, 290), new Point(350, 100) };
MyGraphics.Clear(Color.White);
MyGraphics.DrawBeziers(MyPen, MyPoints);
pictureBox1.Image = MyBitmap;
- 2022-03-25 22:38:21下载
- 积分:1
-
C#读取文件内容显示在DataGridView表格中
Visual C#在DataGridView单元格中显示文本文件的内容,可以理解为,从外部读取文件内容,将其显示在DataGridView
单元格中,可以看出,本代码中使用了DataTable对象、OleDb.OleDbDataAdapter对象,外部文件的格式暂定为txt,其它格式需要相关解析组件支持,实现本功能并不难,以下几行代码就可大致实现:
string MyPath = System.IO.Directory.GetCurrentDirectory();
string MyConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+MyPath+";Extended Properties="text;HDR=yes;FMT=delimited";";
string MySQL = "select * from 季度订单.txt";
DataTable MyTable = new DataTable();
System.Data.OleDb.OleDbDataAdapter MyAdapter = new System.Data.OleDb.OleDbDataAdapter(MySQL, MyConnectionString);
MyAdapter.Fill(MyTable);
this.dataGridView1.DataSource = MyTable;
运行界面效果请参见下图,完整源码请在本页下载。
- 2022-03-20 07:42:37下载
- 积分:1
-
C# 设置制表位控制文本项的输出位置
C# 设置制表位控制文本项的输出位置,将文字输出成表格的样式:
设置制表位控制文本项的输出位置
string MyText = " 姓名 高等数学 离散数学 数据结构
";
MyText = MyText + "李开斌 95 81 92
";
MyText = MyText + "汤小敏 78 84 75
";
MyText = MyText + "汤柱兰 84 76 82
";
MyText = MyText + "蒋兰坤 85 92 66
";
MyText = MyText + "黄 丽 83 91 75
";
MyText = MyText + "张中姣 75 88 82
";
FontFamily MyFontFamily = new FontFamily("宋体");
Font MyFont = new Font(MyFontFamily, 10, FontStyle.Regular, GraphicsUnit.Point);
Rectangle MyRect = new Rectangle(25, 70, 280, 110);
SolidBrush MyBrush = new SolidBrush(Color.FromArgb(255, 0, 128, 255));
StringFormat MyFormat = new StringFormat();
float[] MyTabArray = { 60, 80, 80 };
MyFormat.SetTabStops(0, MyTabArray);
e.Graphics.DrawString(MyText, MyFont, MyBrush, MyRect, MyFormat);
- 2022-02-28 17:10:41下载
- 积分:1
-
IT行业资产管理系统C#+数据库
IT行业资产管理系统C#+数据库,运行后请先登录,在登录窗口中,有验证码功能。程序主界面菜单功能:资产管理、软件设置、服务项目、资产统计报表、服务统计报表、系统设置、帮助文件。若没有登录,则软件会强制退出。也就是说,本软件需要登录后才能使用。
- 2022-02-06 17:00:09下载
- 积分:1
-
C# 简单嵌套查询的例子
分享一个C# 简单嵌套查询的例子,查询总分在580分以上的学生信息。具体代码如下:
/// 查询数据库信息
/// 方法返回DataTable对象
private DataTable GetGrade()
{
string P_Str_ConnectionStr = string.Format(//创建数据库连接字符串
@"server=WIN-GI7E47AND9RLS;database=db_TomeTwo;uid=sa;pwd=");
string P_Str_SqlStr = string.Format(//创建SQL查询字符串
@"SELECT 学生姓名,学生编号, 性别,出生年月,年龄,所在学院,所学专业 FROMtb_Student WHERE 学生编号 IN (SELECT 学生编号 FROM tb_Grade WHERE 总分>=580)");
SqlDataAdapter P_SqlDataAdapter = new SqlDataAdapter(//创建数据适配器
P_Str_SqlStr, P_Str_ConnectionStr);
DataTable P_dt = new DataTable();//创建数据表
P_SqlDataAdapter.Fill(P_dt);//填充数据表
return P_dt;//返回数据表
}
- 2022-12-23 02:20:03下载
- 积分:1
-
C# 锁定线程释放Mutex对象
C# 锁定线程释放Mutex对象的例子,与锁定线程相比,多了释放Mutex对象的功能,实现方法和思路大致差不多:
C#锁定线程,可编写以下代码:
Program myProgram = new Program();//实例化类对象
myProgram.LockThread();//调用锁定线程方法
C# 释放Mutex对象,可编写以下代码:
Mutex myMutex = new Mutex(false);//实例化Mutex类对象
myMutex.WaitOne();//阻止当前线程
Console.WriteLine("锁定线程以实现线程同步");
myMutex.ReleaseMutex();//释放Mutex对象
完整可运行源码实例,请下载本源码。
- 2022-08-10 07:43:23下载
- 积分: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# 修复Access数据库的一个范例程序
C# 修复Access数据库的一个范例程序,不过不知道到底能不能修复吧,这个修复过程的编写,可参考以下代码:
//声明临时数据库的名称
string temp = DateTime.Now.Year.ToString();
temp += DateTime.Now.Month.ToString();
temp += DateTime.Now.Day.ToString();
temp += DateTime.Now.Hour.ToString();
temp += DateTime.Now.Minute.ToString();
temp += DateTime.Now.Second.ToString() + ".bak";
temp = strPathMdb.Substring(0, strPathMdb.LastIndexOf("") + 1) + temp;
//定义临时数据库的连接字符串
string temp2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + temp;
//定义目标数据库的连接字符串
string strPathMdb2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strPathMdb;
JRO.JetEngineClass jt = new JRO.JetEngineClass();//创建一个JetEngineClass对象
//使用JetEngineClass对象的CompactDatabase方法压缩修复数据库
jt.CompactDatabase(strPathMdb2, temp2);
File.Copy(temp, strPathMdb, true);//拷贝临时数据库到目标数据库(覆盖)
File.Delete(temp);//删除临时数据库
MessageBox.Show("修复完成");
这个程序中使用了三个类库:Interop.ADODB.dll、Interop.ADOX.dll、Interop.JRO.dll。
- 2022-01-26 03:31:51下载
- 积分:1