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 6969067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:32:01+00:00 2026-05-27T16:32:01+00:00

Actually, I have fired an event on DataGridView_CellContentClick which perform an operation relating to

  • 0

Actually, I have fired an event on DataGridView_CellContentClick which perform an operation relating to datagridview like changing cell’s value But before performing this action i want to make changes(or fire) an another operation on another control i.e. ListView .But this is not gone happens although i place another operation before datagridview’s operation. Anybody please help me out.

And my code goes like this:-

    private void dGridDeviceList_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
        //DataGridViewCell dcell = dGridDeviceList.Rows[e.RowIndex].Cells[e.ColumnIndex];
        if (e.RowIndex >= 0)
        {
            ListViewItem litem1 = lvInformation.Items.Add("101");

            litem1.SubItems.Add(string.Empty);
            litem1.SubItems[1].Text = "Connected.";

          ListViewItem litem5=  lvErrorList.Items.Add("check ");
            Cursor = Cursors.WaitCursor;
            List<cException> cxp = new List<cException>();
            cDeviceModel cdm = new cDeviceModel();
            ListViewItem litem = new ListViewItem();
            DataGridViewRow drow = new DataGridViewRow();
            cDeviceUtility cUtil = new cDeviceUtility();
            List<cAction> catn = new List<cAction>();
            drow = dGridDeviceList.Rows[e.RowIndex];
            cdm = (cDeviceModel)drow.Tag;
            if (e.ColumnIndex == 6)
            {

                if (dGridDeviceList.CurrentCell.Value.ToString() == "Connect")
                {
                    litem1= lvInformation.Items.Add("101");

                   litem1.SubItems.Add(string.Empty);
                   litem1.SubItems[1].Text = "Connected.";

                    //lvInformation.Items.Insert(0, "101");
                    //lvInformation.Items[0].SubItems.Add("Connected");
                }
                // connect disconnect button column
                if (cdm.IsConnected)
                {
                    ListViewItem litem2 = lvInformation.Items.Add("102");

                    litem2.SubItems.Add(string.Empty);
                    litem2.SubItems[1].Text =string.Format("Disconnecting from {0} device.",dGridDeviceList.CurrentRow.Cells["colDeviceName"].Value);

                    // then disconnect the device
                    cdm.IsConnected = false;
                    cdm.DeviceInterface.Disconnect();
                    dGridDeviceList.Rows[e.RowIndex].Tag = cdm;
                    dGridDeviceList.Rows[e.RowIndex].Cells[6].Value = "Connect";
                    dGridDeviceList.Rows[e.RowIndex].Cells[1].Value = img16x16.Images["notconnected"];
                    dGridDeviceList.Rows[e.RowIndex].Cells[8].Value= 0;
                    dGridDeviceList.Rows[e.RowIndex].Cells[8].Tag = "Not Connected";
                    dGridDeviceList.Refresh();
                    litem2 = lvInformation.Items.Add("103");
                    litem2.SubItems.Add(string.Empty);
                    litem2.SubItems[1].Text = string.Format("Disconnected from {0} device.", dGridDeviceList.CurrentRow.Cells["colDeviceName"].Value);
                }
                else
                {
                   // string test = lvInformation.Items[0].SubItems[1].ToString();
                   // catn.Add(new cAction { Number = lvInformation.Items.Count+1, Message = string.Format("Trying to connect with {0}", dGridDeviceList.Rows[e.RowIndex].Cells["colDeviceName"].Value) });
                   //// lvInformation.Items.Clear();
                   // foreach (cAction Actn in catn)
                   // {
                   //  litem=lvInformation.Items.Insert(0, (lvInformation.Items.Count + 1).ToString());
                   //    litem.SubItems.Add(catn[catn.Count -1].Message);
                   // }
                    // then connect the device
                    if (!ConnectToDevice(ref drow, out cxp) == true)
                    {
                        foreach (cException err in cxp)
                        {
                            litem = lvErrorList.Items.Insert(0, err.Number.ToString());
                            if (err.EType == ErrorType.Error)
                            {
                                litem.ImageKey = "error";
                            }
                            else if (err.EType == ErrorType.Warning)
                            {
                                litem.ImageKey = "warning";
                            }
                            else if (err.EType == ErrorType.Information)
                            {
                                litem.ImageKey = "information";
                            }
                            litem.SubItems.Add(err.Message);
                            litem.SubItems.Add(err.Source);
                        }
                    }
                    else
                    {
                        dGridDeviceList.Rows[e.RowIndex].Cells[0].Value = true;
                        dGridDeviceList.Rows[e.RowIndex].Tag = drow.Tag;
                        dGridDeviceList.Rows[e.RowIndex].Cells[6].Value = "Disconnect";
                        dGridDeviceList.Rows[e.RowIndex].Cells[1].Value = img16x16.Images["connected"];
                        dGridDeviceList.Rows[e.RowIndex].Cells[8].Value = 0;
                        dGridDeviceList.Rows[e.RowIndex].Cells[8].Tag = "Ready";
                        dGridDeviceList.Refresh();
                        RemoveSelectionRow();
                    }
                }
            }
            else if (e.ColumnIndex == 7)
            {
                // view logs button column
                pbarMain.Value = 100;
                ViewLogs(dGridDeviceList.Rows[e.RowIndex],ref lvAttnLog ,ref lvErrorList);
            }
            Cursor = Cursors.Arrow;
        }
    }
  • 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-27T16:32:02+00:00Added an answer on May 27, 2026 at 4:32 pm

    considering this is winform

     private void buttonCopyContent_Click(object sender, EventArgs e)
    {
    //do something
    }
    

    you can call this event via following line
    this.Invoke(new EventHandler(buttonCopyContent_Click));

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

Sidebar

Related Questions

I have a DataGridView and a handler for the EditingControlShowing event which is used
I actually have an answer to my question but it is not parallelized so
I actually have two questions regarding the same problem but I think it is
I'm having a problem.. Actually I do have an issue when sending a value
Say I have a DataGridView in which I dynamically build up a ComboBox column
I have an EntityDataSource with OnSelected event (fired after finished query). The event handler
I actually have right now two questions: 1) What font faces are preferred for
I actually have two questions regarding exception/error handling in the iPhone app that I
I actually have 2 queries: How do I display the data of a variable
I have heard that it's best not to actually have any html in your

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.