-
C# 使用DrawPolygon方法绘制一个多边形
C# 调用Graphics对象的DrawPolygon方法绘制一个多边形,我们用代码定义多边形的每条边:Point point6 = new Point(160, 20); //实例化Point类,注意多边形的每个边都需要定义不同数据。
Point[] myPoints ={ point1, point2, point3, point4, point5, point6 };//创建Point结构数组
//调用Graphics对象的DrawPolygon方法绘制一个多边形
ghs.DrawPolygon(myPen, myPoints);
- 2022-02-03 12:31:32下载
- 积分:1
-
C# 在LINQ to DataSet中对分组操作执行子查询
C# 在LINQ to DataSet中对分组操作执行子查询,相关代码:
private void button1_Click(object sender, EventArgs e)
{//在LINQ to DataSet中对分组操作执行子查询
SqlConnection MyConnection = new SqlConnection();
MyConnection.ConnectionString = @"Data Source =.SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True";
MyConnection.Open();
SqlCommand MyCommand = new SqlCommand("Select * From Orders ", MyConnection);
DataSet MySet = new DataSet();
SqlDataAdapter MyAdapter = new SqlDataAdapter(MyCommand);
MyAdapter.Fill(MySet);
DataTable MyQueryTable = MySet.Tables[0];
var MyQuery = from MyOrder in MyQueryTable.AsEnumerable()
orderby MyOrder.Field("ShipCity")
group MyOrder by MyOrder.Field("ShipCity") into g
select new
{
MyCity = g.Key,
MyMaxFreight = (from MyData in g select MyData.Field("Freight")).Max()
- 2022-01-27 20:20:32下载
- 积分:1
-
C# 向SQL Server数据库中批量写入超多数据
Visual C# 向SQL Server数据库中批量写入海量数据,这个虽然不是“大数据”,但这个海量数据也是很考验SQL的负载能力和代码的执行效率。那么C#如何实现效率高、速度快的数据写入呢,这个例子是来自C#开发实战1200例(第Ⅱ卷)中的代码改良,请下载源码后查看,里面有注释。
- 2022-04-17 17:11:12下载
- 积分:1
-
C# 编写多种窗口排列方式的MDIForm窗体
C# 实现MDIForm窗体功能,代码中实现了3个MDI子窗口,并以水平平铺、垂直平铺、层叠排列的方式实现多种子窗口的排列布局,其主要代码在form1.cs中,其它文件为生成子窗口的文件,关键代码如下:
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();//实例化Form2
frm2.MdiParent = this;//设置MdiParent属性,将当前窗体作为父窗体
frm2.Show();//使用Show方法打开窗体
Form3 frm3 = new Form3();//实例化Form3
frm3.MdiParent = this;//设置MdiParent属性,将当前窗体作为父窗体
frm3.Show();//使用Show方法打开窗体
Form4 frm4 = new Form4();//实例化Form4
frm4.MdiParent = this;//设置MdiParent属性,将当前窗体作为父窗体
frm4.Show();//使用Show方法打开窗体
}
private void 水平平铺ToolStripMenuItem_Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.TileHorizontal);//使用MdiLayout枚举实现水平平铺
}
private void 垂直平铺ToolStripMenuItem_Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.TileVertical);//使用MdiLayout枚举实现垂直平铺
}
private void 层叠排列ToolStripMenuItem_Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.Cascade);//使用MdiLayout枚举实现层叠排列
}
- 2022-03-07 15:00:14下载
- 积分:1
-
C# 中的MaskedTextBox控件用法示例
C# 中的MaskedTextBox控件用法示例,类似于掩码功能的文本框,比如密码框,不会显示出用户输入的字符。本示例将向大家介绍如何将数据绑定到MaskedTextBox控件。
不过本例需要连接数据库,连接好后,用户可通过窗口上的上一电话号码、下一电话号码来查看演示。
- 2022-03-24 22:11:34下载
- 积分:1
-
录音程序
自己做的小程序,在VC++6.0下编译通过
- 2022-02-28 14:04:03下载
- 积分:1
-
C#在listView自定义imageList图标列表
C#在listView自定义imageList图标列表,实际上是创建了一个图像列表的Listview列表,我们可以将一些菜单条目做成此类型,以图标的风格展现操作选项,本实例中你可以熟悉imageList、listView1列表项的添加与删除。
下面是关键的代码:
listView1.LargeImageList = imageList1;
imageList1.ImageSize = new Size(37,36);
imageList1.Images.Add(Image.FromFile("01.png"));调用图标显示的图像资源
imageList1.Images.Add(Image.FromFile("02.png"));
listView1.SmallImageList = imageList1;
listView1.Items.Add("明日科技");图标下边显示的文字
listView1.Items.Add("C#编程词典");
listView1.Items[0].ImageIndex = 0;
listView1.Items[1].ImageIndex = 1;
- 2023-03-09 08:05:03下载
- 积分:1
-
C#演示用Brush填充Rectangle图形
C#画矩形,然后使用Brush填充Rectangle图形,单击按钮后会生成一个填充过的图形,需要创建Graphics对象,创建一个Brush对象,再使用Rectangle绘制一个矩形,然后使用Brush填充,实现这一过程,核心代码如下:
private void button1_Click(object sender, EventArgs e)
{
Graphics ghs = this.CreateGraphics();//创建Graphics对象
Brush mybs = new SolidBrush(Color.Red);//使用SolidBrush类创建一个Brush对象
Rectangle rt = new Rectangle(10, 10, 100, 100);//绘制一个矩形
ghs.FillRectangle(mybs, rt);//用Brush填充Rectangle
}
- 2022-07-06 17:10:54下载
- 积分:1
-
c#web代理服务器源码
c#web代理服务器源码,可以实现 http socks5 ftp等代理。
- 2023-03-30 06:10:04下载
- 积分:1
-
C# WPF 功能打印的示例
C# WPF 功能打印的示例,加载内容后,可在本程序中直接打印出XAML文档。
private void button2_Click(object sender, RoutedEventArgs e)
{//打印文件
PrintDialog MyDialog = new PrintDialog();
if ((MyDialog.ShowDialog() == true))
{
MyDialog.PrintVisual(this.richTextBox1 as Visual, "我的XAML打印文档");
}
}
private void button3_Click(object sender, RoutedEventArgs e)
{//保存文件
string MyFileName = "MyFile.XAML";
TextRange MyTextRange;
System.IO.FileStream MyStream;
MyTextRange = new TextRange(this.richTextBox1.Document.ContentStart, this.richTextBox1.Document.ContentEnd);
MyStream = new System.IO.FileStream(MyFileName, System.IO.FileMode.Create);
MyTextRange.Save(MyStream, DataFormats.XamlPackage);
MyStream.Close();
}
- 2022-01-23 10:57:00下载
- 积分:1