社区
C#
帖子详情
winform 为何在运行时,用鼠标拖动窗体没反应???
erictang2003
2004-03-25 11:18:16
启动后,程序开始访问EXCEL 文件,但读取过程中,用鼠标拖动窗体没反应???
知道所有读取完成后,才能拖动.
怎样解决?
...全文
180
13
打赏
收藏
winform 为何在运行时,用鼠标拖动窗体没反应???
启动后,程序开始访问EXCEL 文件,但读取过程中,用鼠标拖动窗体没反应??? 知道所有读取完成后,才能拖动. 怎样解决?
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
13 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
erictang2003
2004-03-27
打赏
举报
回复
up
HNU
2004-03-26
打赏
举报
回复
save & up
marvelstack
2004-03-26
打赏
举报
回复
要使用多线程就行了,
如下面是我写的代码,
楼主可以看看,对你会有帮助
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
namespace WindowsApplication1
{
//定义代理
public delegate void OccuredHandler(string msg);
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
//定义事件
public event OccuredHandler Occured;
//定义线程
Thread myThread;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button2;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
//注册事件
this.Occured +=new OccuredHandler(Form1_Occured);
myThread = new Thread(new ThreadStart(RunThread));
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(184, 32);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "运行";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(32, 112);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(192, 23);
this.label1.TabIndex = 1;
this.label1.Text = "label1";
//
// button2
//
this.button2.Location = new System.Drawing.Point(184, 72);
this.button2.Name = "button2";
this.button2.TabIndex = 2;
this.button2.Text = "退出";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button2);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
//线程方法
public void RunThread()
{
for(int i=0;i<1000000;i++)
{
this.label1.Text = i.ToString();
}
//激发事件
Occured("终于结束了,大哥快冒烟了!");
}
//线程结束通知函数
private void Form1_Occured(string msg)
{
MessageBox.Show(msg);
}
private void button1_Click(object sender, System.EventArgs e)
{
myThread.Start();
this.button1.Enabled = false;
}
private void button2_Click(object sender, System.EventArgs e)
{
//if(myThread.ThreadState!=ThreadState.Stopped||myThread.ThreadState!=ThreadState.Aborted)
myThread.Abort();
Application.Exit();
}
}
}
erictang2003
2004-03-26
打赏
举报
回复
up
yanransoft
2004-03-26
打赏
举报
回复
多线程操作
Napoleo
2004-03-26
打赏
举报
回复
用后台线程啦,比异步代理简单100倍
erictang2003
2004-03-26
打赏
举报
回复
up
HNU
2004-03-26
打赏
举报
回复
save
erictang2003
2004-03-26
打赏
举报
回复
有没有真正可用的代码?
wolftop
2004-03-25
打赏
举报
回复
开个线程处理打开和读取EXCEL~!
huangsuipeng
2004-03-25
打赏
举报
回复
用异步委托
delegate int Count(int a);
Count del =new Count(你的函数);
IAsyncReslut ar =del.BeginInvoke(10000,null,null);
.............
if(ar.IsCompleted)
{
int count=del.EndInvoke(ar);
}
else
{
以后再试
}
也可以使用CALLBACK方式
delegate int Count(int a);
Count del =new Count(你的函数);
AsyncCallback ab=new AsyncCallback(yourcallback)
IAsyncReslut ar =del.BeginInvoke(10000,ab,null);
.............
恶猫
2004-03-25
打赏
举报
回复
你读取是用的循环?还是...一次全部读取完??
如果是循环.
那么在循环内部加:
Application.DoEvents() (自己看大小写,我忘了)
如果是一次全部读完,
那你就要新建一个线程,另外读取那个文件了..
ipromise
2004-03-25
打赏
举报
回复
试着加一个读取线程,交给后台处理
【转】C#
WinForm
中Panel实现用
鼠标
操作滚动条
由于在
WinForm
中Panel不能直接响应
鼠标
的滚动事件,只好采用捕获
窗体
的滚动事件。 方法如下: 在
窗体
的Load事件注册滚动事件,并增加对应的方法 private void FormSample_Load(object sender, EventArgs e) ...
【
WinForm
.NET开发】Windows
窗体
开发概述
使用 Windows
窗体
,可以开发包含丰富图形的应用,这些应用易于部署和更新,并且在脱机状态下或连接到 Internet 时都可正常工作。Windows
窗体
应用可以访问运行应用的计算机的本地硬件和文件系统。
Winform
中panel的mousewheel
鼠标
滚轮事件触发
Winform
中panel的mousewheel
鼠标
滚轮事件触发
在
WinForm
中使用进度条展示长时间任务的执行进度
今天有人问道如何在
WinForm
程序中,使用进度条显示长时间任务的执行进度。 这个问题是一个开发中很常见的问题,正好也整理和总结一下。 这个问题我们从两个部分来看,第一,长时间执行的任务如何暴露出其...
Dean的周学习内容 24.4.22~28:
Winform
Winform
= Windows Form = Windows
窗体
是一个可创建适用于 Windows 的丰富桌面客户端应用的 UI 框架。开发功能包括:控件(支持自定义控件)、图形、数据绑定、用户输入。在 Windows
窗体
中,
窗体
是一种可视图面,...
C#
111,092
社区成员
642,554
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章