Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have simple question. How do I pause program? I want to change pictures very slowly.
My code:
private void button2_Click(object sender, EventArgs e){
Image picture1 = Program.Properties.Resources.picture1;
Image picture2 = Program.Properties.Resources.picture2;
Button1.Image = picture1
//Here I want pause
Button1.Image = picture2
}
If you want procedural code (like in your example), without timers and without locking the UI:
await Task.Delay(1000)
You can use Threads or Timers.
http://msdn.microsoft.com/en-us/library/swx5easy.aspx
http://programmingbaba.com/how-to-stop-system-threading-timer-in-c-do-net/
Or you can use Sleep method to puase your program.
http://www.dotnetperls.com/sleep
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
With each click on the picture box the number in the output label must decrement by one.
You need an event handler for the clicking of the image, and an int to keep track of how many times it was clicked; here is some pseudocode to get you started:
int timesClicked = 42;
private void Img_Click(sender object, eventargs e)
{
timesClicked--;
UpdateLabel();
}
internal void UpdateLabel()
{
label.Caption = timesClicked.ToString();
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I want to do something like this:
Button button = new Button("Button");
button.addClickListener(new ClickListener(){
//Implement required methods here..
});
How can i do this in C#?
Attach the event handler:
button.Click += myClickEvent;
...
protected void myClickEvent(Object sender, EventArgs e)
{
// do your thing
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Thank you for your time in advance, I need some help, I want to create a DataGridView in Windows form, and in this grid I want to enter data and when I hit enter it should save that data to database and create another line, I tried to find a good tutorial on it but didn’t succeeded. if there is any good example please let me know
And please I do NOT need the grid with save update etc buttons, It should save data upon hit enter and cursor moves to the next line of the grid
If there is any tutorial or example please let me know
You simply catch the Enter-key in the DataGridView.KeyDown event:
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
yourSaveRoutine();
dataGridView1.Rows.Add();
}
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i have this project in my visual studio and i have a form which is linked to a solution in a project.
So, i need to call it on a button click.
It's like:
private void button1_Click(object sender, EventArgs e)
{
poComp.Client.StartpoComp
}
The thing is i have not copied the code the right way, houw should it proceed?
What is the file's structure?
Sorry, i know this might sound dumb and it probably is but i'm right in the beginning.
Below will do what (I think) you want to do but I strongly advise that you google "using classes c#" to try and find some tutorials
Here is just one
private void button1_Click(object sender, EventArgs e)
{
StartpoComp spc = new poComp.Client.StartpoComp();
//myFormsLabel.Text = spc.SomePublicVariable;
//spc.SomePublicMethod(param1);
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have a send email method with a foreach, like this:
static void Main(string[] args)
{
foreach(var user in GetAllUsers())
{
SendMail(user.Email);
}
}
I need to improve that method. Using a multithread, because i dont want to wait the SendMail method executes each time for each user.
Any sugestions to do that?
Thanks
Try using a parallel foreach. I.e.
Parallel.ForEach(GetAllUsers(), user=>
{
SendMail(user.Email);
});
You can try something like this
private void Send()
{
Parallel.Foreach(GetAllUsers(), user =>
{
SendMail(user.Email);
});
}
I think the easiest way to do this would be thread pooling. .Net makes this pretty easy and you can read more about it here.