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

  • SEARCH
  • Home
  • 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 7408291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:53:18+00:00 2026-05-29T05:53:18+00:00

I have this button with the code: private void button22_Click_1(object sender, EventArgs e) {

  • 0

I have this button with the code:

   private void button22_Click_1(object sender, EventArgs e)
    {
        Separare sp = new Separare(dataGridView1,label_pin.Tag.ToString(),label_pin.Text);
        sp.FormClosed += new FormClosedEventHandler(ClosedForm);
        sp.Show();

    }

The FormClosedEventHandler looks like this:

   DataTable bon_temp = bon_tempTableAdapter.GetDataByTable(label_pin.Tag.ToString());

        foreach (DataRow row in bon_temp.Rows)
        {
            AddRow(row.ItemArray[3].ToString(), Convert.ToInt32(row.ItemArray[4]), Convert.ToDecimal(row.ItemArray[5]));
            Console.WriteLine(row.ItemArray[3].ToString(), Convert.ToInt32(row.ItemArray[4]), Convert.ToDecimal(row.ItemArray[5]));
        }

        bon_tempTableAdapter.DeleteQuery(label_pin.Tag.ToString());

where the AddRow method adds rows to DataGridView. My problem is that when i close the sp form the rows are not added to the DataGridView.

  • 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-05-29T05:53:19+00:00Added an answer on May 29, 2026 at 5:53 am

    FormClosed occurs whenever the user closes the form, after the form has been closed and specifies the close reason.

    The reason for your code not working might be that some controls on the form are already destroyed…

    I suggest you use FormClosing event which occurs whenever the user closes the form, before the form has been closed and specifies the close reason.

    Example code (it is very similar to what you did above):

    this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MyMainForm_FormClosing);
    
    ...
    
    private void MyMainForm_FormClosing(object sender, FormClosingEventArgs e)
    {
      //your code goes here
      //optionally, you can get or set e.Cancel which gets or sets a value indicating that the event should be cancelled; in this case the form won't close if you cancel it here
      //or, you can check e.CloseReason which gets a value that indicates why the form is being closed (this is an enum Systems.Windows.Forms.CloseReason)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: private void button2_Click(object sender, EventArgs e) { //add pgs selected
I have this code: 001 private void uiButton1_Click(object sender, EventArgs e) 002 { 003
I have this on a button: private void Button_Click(object sender, RoutedEventArgs e) { string
I have this code: private void Form1_KeyDown(object sender, KeyEventArgs e) { MessageBox.Show(Fail!); } And
Hello I'm having a problem here. The code looks like this. private void Form3_Load(object
I have this C# code to enumerate controls of a Form instance: private void
I have this code in the end of link button click: Response.ContentType = application/zip;
I have this code that has one button that let's me choose an entry
Here's my problem - I have some code like this: <mx:Canvas width=300 height=300> <mx:Button
I have a silverlight application. This contains a preview button. Button code is as

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.