Google [站内搜索]

分类: Win编程预览模式: 普通 | 列表

CYQ.Data开源数据层框架使用示例

一、准备工具

创建Sqlite数据库test.db,添加表Person:

Create TABLE Person (

查看更多...

分类:Win编程 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 4742
今天发现刚写的WinForm应用程序占用内存不正常,经分析测试发现是由于多次创建WebBrowser控件导致,为了便于说明问题,下边是简化后的代码:

Form1.cs:
public partial class Form1 : Form
{

查看更多...

分类:Win编程 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2630
今天将一个Winform窗体设计成最大化后,运行发现它遮盖了系统任务栏,经多次测试发现原来是同时禁用了最大化按钮且设置窗体边框样式为FormBorderStyle.FixedSingle才会出现这种情况:

private void Form1_Load(object sender, EventArgs e)
{
    this.MaximizeBox = false;

查看更多...

分类:Win编程 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 3558

Application.DoEvents使用示例

例如有下边一段代码,当程序运行后,从点击按钮到退出循环这段时间,整个应用程序将“卡死”,文本框一直空白最后突然显示10000:

private void button1_Click(object sender, EventArgs e)
{
    for (int i = 1; i <= 10000; i++)

查看更多...

分类:Win编程 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 3189

WebBrowser.DocumentText中文乱码解决方法

private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
    WebBrowser wb = sender as WebBrowser;
    Encoding encoding = Encoding.GetEncoding(wb.Document.Encoding);
    using (StreamReader stream = new StreamReader(wb.DocumentStream, encoding))

查看更多...

分类:Win编程 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 3406
public class WebBrowserEventManager
{
    private EventHandlerList _ehList = new EventHandlerList();
    private WebBrowser _wb = null;

查看更多...

分类:Win编程 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 5789

WPF应用程序入口函数(Main函数)小结

Windows窗体应用程序的入口函数在Program.cs文件中,但WPF应用程序没有这个文件,WPF应用程序入口函数在哪里呢?手工添加一个入口函数,生成项目,出错:



原来WPF应用程序入口函数在obj\Release\App.g.cs文件中:

查看更多...

分类:Win编程 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 6758
不使用表达式树:

var query = context.People.Where(item => item.Age == 20);

引用内容 引用内容
Select
    [Extent1].[Id] AS [Id],

查看更多...

分类:Win编程 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2183

RichTextBox.Find遍历搜索字符串中的坑

RichTextBox.Find遍历搜索字符串有两个重载方法可供调用:

public int Find(string str, int start, RichTextBoxFinds options);
public int Find(string str, int start, int end, RichTextBoxFinds options);

经测试发现:在特定场合下这两个重载方法可能发生死循环,下面分别举栗说明。

查看更多...

分类:Win编程 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 3659
今天使用LINQ to Entities时出现了一个错误,为方便说明创建了个Demo表用于还原问题:

create table Person
(
    Id int identity(1,1) primary key,

查看更多...

分类:Win编程 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 5393