在Windows窗体中显示加载图像 [英] Showing the loading image in windows Forms
问题描述
大家好,
i我正在工作的网络服务。
当我拨打网络服务时可以接受超过5分钟从webservices读取数据。那个时候有点刺激。所以我想要显示.gif图像那个时间iam做了但是它没有用。
让我知道我该怎么做。
我的代码(窗体形式)
1)iam take grid
2)另一种形式有进度条控制
3)当我打电话给webservice时,另一个表格正在显示
4)当我完成网络服务时,另一个表格正在关闭
这个对我不起作用
我的代码
我调试binddata调用,否则不调用我不知道发生了什么
所以让我知道我错在哪里有另一种方法来做这个
公共部分类Form12:表格
{
Test_Service Testsrvc = new Test_Service();
测试[]测试;
private Thread;
//进度条形式
private Form5 objFrm5 = new Form5();
public Form12()
{
InitializeComponent();
加载+ =新的EventHandler(Form12_Load);
}
private void ShowDialog()
{
if(this.InvokeRequired)
{
objFrm5.ShowDialog( );
}
else
{
//启动将执行此方法的线程
th = new System.Threading.Thread(Binddata);
th.IsBackground = true;
th.Start();
}
}
void Form12_Load(对象发送者,EventArgs e)
{
ShowDialog();
if(th!= null)
{
th.Abort();
objFrm5.Close();
}
}
private void Binddata()
{
Testsrvc.Credentials = new System.Net.NetworkCredential(UserName ,Pwd);
test = Testsrvc.ReadMultiple(null,null,0);
dataGridView1.DataSource = Test;
pictureBox1.Visible = false;
progressBar1.Visible = false;
}
}
在Windows窗体上显示加载动画 [ ^ ]
从C#中的资源加载图像 [ ^ ]
加载位图和DLL文件中的图像 [ ^ ]
委托void ProcessDelegate();
void Form12_Load(object sender,EventArgs e)
{
ProcessDelegate del = new ProcessDelegate(Binddata);
del.BeginInvoke(new AsyncCallback(EndProcess),del);
//它可以处理交叉线程
Control.CheckForIllegalCrossThreadCalls = false;
}
void EndProcess(IAsyncResult result)
{
if(result.IsCompleted)//如果异步操作的结果为真(完成)则;
{
ProcessDelegate del = result.AsyncState as ProcessDelegate;
del.EndInvoke(result);
}
}
现在工作正常。
hi
在windows窗体中,动画gif无法正常工作。它只能在浏览器中使用。如果你想创建一个动画,使用wpf创建它,你可以添加你的winform。
hi all,
i am working webservices.
when i call the webservice it can take more than 5minutes to read the data from webservices. that time little bit irritating. So i want to showing the .gif image that time iam did that but it's not working.
let me know how can i do this.
in my code (windows forms)
1) iam taking grid
2) another form have progressbar control
3) when i call the webservice anotherform is showing
4) when i complete the webservice calling another form is closing
this is not working for me
in my code
when ever i debug the binddata calling otherwise not calling i don't know what's going on
so let me know where i wrong is there another way to do this
public partial class Form12 : Form { Test_Service Testsrvc = new Test_Service(); Test[] test; private Thread th; //progressbar form private Form5 objFrm5 = new Form5(); public Form12() { InitializeComponent(); Load += new EventHandler(Form12_Load); } private void ShowDialog() { if (this.InvokeRequired) { objFrm5.ShowDialog(); } else { //Start the thread that will execute this method th = new System.Threading.Thread(Binddata); th.IsBackground = true; th.Start(); } } void Form12_Load(object sender, EventArgs e) { ShowDialog(); if (th != null) { th.Abort(); objFrm5.Close(); } } private void Binddata() { Testsrvc.Credentials = new System.Net.NetworkCredential("UserName", "Pwd"); test = Testsrvc.ReadMultiple(null, null, 0); dataGridView1.DataSource = Test; pictureBox1.Visible = false; progressBar1.Visible = false; } }
Showing Loading Animation on Windows Form[^]
Load image from resources in C#[^]
Loading Bitmaps and Images in DLL files[^]
finally i did after knowing the delegate concepts.
delegate void ProcessDelegate(); void Form12_Load(object sender, EventArgs e) { ProcessDelegate del = new ProcessDelegate(Binddata); del.BeginInvoke(new AsyncCallback(EndProcess), del); //it can handle the cross threading Control.CheckForIllegalCrossThreadCalls = false; } void EndProcess(IAsyncResult result) { if (result.IsCompleted) //if the async operation's result is true (done) then; { ProcessDelegate del = result.AsyncState as ProcessDelegate; del.EndInvoke(result); } }
now it's working fine.
hi
In windows form the animated gif wont work. It will only work only in browsers. If you want to create an animation, make it using wpf and you can add it your winform.
这篇关于在Windows窗体中显示加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!