请问大家winform怎么自动刷新显示记录
请问大家winform怎么自动刷新显示记录 --------------------编程问答-------------------- 用timer定时刷新 --------------------编程问答-------------------- 能给个例子么?我写的那个太占资源。 --------------------编程问答-------------------- 占资源的话就单个数据刷新。。。
没改变的就不要刷 --------------------编程问答-------------------- 单个数据刷新--什么意思,请给个提示 --------------------编程问答-------------------- Timer1_time()
{
refreshData();
}
void RefreshData();
{
//取数据
} --------------------编程问答-------------------- 我错在哪里了?
public class Monitor : System.Windows.Forms.Form
{
private string strSQL = "";
private LinkDataBase linkDB = new LinkDataBase();
private DataView myDataView;
private DataSet myDataSet = new DataSet();
private System.Windows.Forms.GroupBox grpBxAccept;
private System.Windows.Forms.GroupBox grpBxSend;
private System.Windows.Forms.DataGrid dgAccept;
private System.Windows.Forms.Timer tmListMessage;
private System.ComponentModel.IContainer components;
public Monitor()
{
InitializeComponent();
this.Top100AcceptMessage();
this.DataGridStateControl();
}
/// <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.components = new System.ComponentModel.Container();
this.grpBxAccept = new System.Windows.Forms.GroupBox();
this.dgAccept = new System.Windows.Forms.DataGrid();
this.grpBxSend = new System.Windows.Forms.GroupBox();
this.tmListMessage = new System.Windows.Forms.Timer(this.components);
this.grpBxAccept.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgAccept)).BeginInit();
this.SuspendLayout();
//
// grpBxAccept
//
this.grpBxAccept.Controls.Add(this.dgAccept);
this.grpBxAccept.Location = new System.Drawing.Point(8, 16);
this.grpBxAccept.Name = "grpBxAccept";
this.grpBxAccept.Size = new System.Drawing.Size(504, 504);
this.grpBxAccept.TabIndex = 0;
this.grpBxAccept.TabStop = false;
this.grpBxAccept.Text = "接受消息";
//
// dgAccept
//
this.dgAccept.CaptionVisible = false;
this.dgAccept.DataMember = "";
this.dgAccept.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dgAccept.Location = new System.Drawing.Point(8, 24);
this.dgAccept.Name = "dgAccept";
this.dgAccept.Size = new System.Drawing.Size(480, 464);
this.dgAccept.TabIndex = 0;
//
// grpBxSend
//
this.grpBxSend.Location = new System.Drawing.Point(528, 16);
this.grpBxSend.Name = "grpBxSend";
this.grpBxSend.Size = new System.Drawing.Size(384, 496);
this.grpBxSend.TabIndex = 1;
this.grpBxSend.TabStop = false;
this.grpBxSend.Text = "发送消息";
//
// tmListMessage
//
this.tmListMessage.Enabled = true;
this.tmListMessage.Interval = 2000;
this.tmListMessage.Tick += new System.EventHandler(this.tmListMessage_Tick);
//
// Monitor
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(928, 549);
this.Controls.Add(this.grpBxSend);
this.Controls.Add(this.grpBxAccept);
this.Name = "Monitor";
this.Text = "监视消息";
this.grpBxAccept.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dgAccept)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void Top100AcceptMessage()
{
strSQL = "SELECT TOP 100 * FROM [Hb_Accept]";
this.myDataSet = this.linkDB.SelectDataBase(strSQL,"Top100Accept");
this.myDataView = new DataView(myDataSet.Tables[0]);
this.dgAccept.DataSource = myDataView;
}
//-----------设置表格状态--------------
private void DataGridStateControl()
{
DataGridTableStyle ts = new DataGridTableStyle();
DataGridNoActiveCellColumn aColumnTextColumn;
ts.AlternatingBackColor = Color.LightGray;
ts.MappingName = this.myDataSet.Tables[0].TableName;
int numCols = this.myDataSet.Tables[0].Columns.Count;
for (int i = 0;i< numCols;i++)
{
aColumnTextColumn = new DataGridNoActiveCellColumn();
aColumnTextColumn.MappingName = this.myDataSet.Tables[0].Columns[i].ColumnName;
aColumnTextColumn.HeaderText = this.myDataSet.Tables[0].Columns[i].ColumnName;
aColumnTextColumn.NullText = "";
aColumnTextColumn.Format = "D";
ts.GridColumnStyles.Add(aColumnTextColumn);
}
this.dgAccept.TableStyles.Add(ts);
}
private void tmListMessage_Tick(object sender, System.EventArgs e)
{
} --------------------编程问答-------------------- 用Timer控件,
---------------------------
还有就这样让大家看呀;有没有系统错误提示信息呀? --------------------编程问答-------------------- 没有系统错误提示信息。 --------------------编程问答-------------------- up --------------------编程问答-------------------- up --------------------编程问答-------------------- 每天回帖即可获得10分可用分! --------------------编程问答-------------------- 每天回帖即可获得10分可用分! --------------------编程问答-------------------- timer控件行。。。。。。试试。。。。。 --------------------编程问答--------------------
lbl_LJinfo.Text = "准备连接服务器...";
Application.DoEvents();//这个就是刷新界面 可以放在 listbox等控件里 每添加一句或者更新,就加这个在后面
Thread.Sleep(1000);//这个是让你看到效果的,不然一闪而过 ,需要添加引用
RemSSr();
lbl_LJinfo.Text = "连接服务器中...";
Application.DoEvents();
Thread.Sleep(1000);
Loading();
lbl_LJinfo.Text = "连接服务器成功...";
Application.DoEvents();
Thread.Sleep(1000);
补充:.NET技术 , C#