Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8469677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:17:41+00:00 2026-06-10T16:17:41+00:00

how can i clear the datagridview once i click on the cancel button.It will

  • 0
  1. how can i clear the datagridview once i click on the cancel button.It will start the process from starting but before starting new thread i need to clear the datagrid view ever time.

  2. th.Suspend(),th.Resume(),th.Abort() // this is obsolete.
    This has been deprecated. I get these kind of warnings.but still the code i use works okay for me.I never worked on Threads before.

when ever i use Reset(),set() methods it doesnt work. may be i couldnt get idea to use them in a right way. Any suggestion to use in correct way?

ManualResetEvent run=new ManualResetEvent(true); 
ManualResetEvent shut=new ManualResetEvent(false);     
public delegate void GridTestResults(int Sno,string Name,double MinValue,double MaxValue,double Value,string Result,string Time);


public void ValuesToGrid(int Sno,string Name,double MinValue,double MaxValue,double Value,string Result,string Time)
{
    DataRow row=table.NewRow();
    if(this.InvokeRequired)
    {
        GridTestResults grid = new GridTestResults(this.ValuesToGrid);
        this.Invoke(grid,new object[]{Sno,Name,MinValue,MaxValue,Value,Result,Time});
    }
    else
    {
        row["Sno"] = Sno;
        row["Name"] = Name;
        row["MinValue"] = MinValue;
        row["MaxValue"] = MaxValue;
        row["Value"] = Value;
        row["Result"] = Result;
        row["Time"] = Time;
        table.Rows.Add(row);

        dataGridView1.Refresh();

        //How can i clear all the rows of gridview once the
        // its clicks the start button after cancel button
    }
}

 private void Startbutton_Click(object sender, EventArgs e)
{ 
    stopwatch.Start();
    timer1.Start();
    ts=new ThreadStart(ProcessStarted);
    th=new Thread(ts);                 
    th.Start();            
}

private void Pausebutton_Click(object sender, EventArgs e)
{                  
    if (th.ThreadState == System.Threading.ThreadState.Suspended)
    {
        timer1.Enabled = true;
        label5.Enabled = true;
        Pausebutton.Enabled = true;
        th.Resume();  //run.Set(); // this is obsolete.This has been deprecated.
        label3.Text = "The Current thread has resumed again";
    }
    else
    {
        label5.Enabled = false;
        timer1.Enabled = false;
        th.Suspend();  
        //th.Suspend(); // this is obsolete.This has been deprecated.
        label3.Text = "The current thread suspended";
    }
}

private void Cancelbutton_Click(object sender, EventArgs e)
{
    timer1.Stop();
    stopwatch.Stop();

    if (th.ThreadState==System.Threading.ThreadState.Suspended)
    {
         try
        {
             th.Abort();
        }
        catch (Exception)
        {
             th.Resume();
        }

    }
    try
    {
        th.Abort();
        //th.Join();
    }
    catch (Exception)
    {
        th.Resume();
    }
    label3.Text = "The Testprocess stopped completely";

    //dataGridView1.Rows.Clear();
    //dataGridView1.DataSource = null;  
    //i cannot use any of these two way to clear the gridview....
    //gives error like cannot clear the list
    stopwatch.Reset();    
}

private void ProcessStarted()
{
    //all the methods to be shown in datagridview 

void oneMethod()
{
    Application.Run(new OneForm()); 
    //here the form appears as popup window.once
    // we click ok button it will closes automatically.
    //now the problem is when ever i clcik pause button the OneForm will 
    // hangs and when i clcik resume it will work normally.
    // am not sure is it the correct way of doing r not while 
    // working with the threads?
}

    //dataGridView1.Rows.Clear(); 
    //Here also it does not work..gives same exception like 
    //cannot clear the list.
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T16:17:42+00:00Added an answer on June 10, 2026 at 4:17 pm

    Use Datatable clear() to clear the rows of Datatable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I suspend a .NET DataGridView from displaying anything while I update its
I have few doubts regarding Jython and will be happy if someone can clear
Possible Duplicate: How can I clear rows in DataGridView with C#? I am using
I can clear all the layers using mapControl.ClearLayers(), but I only want to clear
I have a doubt, I will appreciate if you can clear it . COOKIES
Using adb shell we can clear application data. adb shell pm clear com.android.browser But
I know you can clear options by doing the following: dropDownList.options.length = 0; Is
Hoping someone can clear this up for me. Let's say I have 2 globals:
Can I clear browser cache of the page when I'm leaving it. // Clear
How can I clear all textboxes / uncheck checkboxes in my asp.net page without

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.