4
Answers

How to check button clicked or not on form?

Member1

Member1

8y
419
1
Hello , 
I have 1 form says A  . I want to perform a task in which form A executing some part of a code which is needed to be execute on button click on same form . Control should wait in that case till button click and after button clicked, bellow code should executes.
 
 Following is my code :
 
private void button1_Click_1(object sender, EventArgs e) //send button//
{
      try
      {
         List<DataGridViewRow> rows_with_checked_column = new List<DataGridViewRow>();
         foreach (DataGridViewRow row in dataGridView1.Rows)
         {
               if (Convert.ToBoolean(row.Cells[Column4.Name].Value) == true)
               {
                      rows_with_checked_column.Add(row);
               }
         }
         foreach (DataGridViewRow row in dataGridView1.Rows)
         {
               if (Convert.ToBoolean(row.Cells[Column4.Name].Value) == true)
               {
                  for (int i = 0; i <= row.Cells.Count - 1; i++)
                  {
                     row.Cells[i].Style.BackColor = Color.Aqua;
                     // data = row.Cells[1].Value.ToString();
                  }
               }
            row.Cells[Column4.Name].Value = false;
            }
         }
      catch { }
}
 
 the method::
 
case "_":
if (res.StartsWith("_"))
{
     System.Windows.Forms.MessageBox.Show("Send indent to Device");
      unscr = Encoding.ASCII.GetBytes("@!#");
      networkStream.Write(unscr, 0, unscr.Length);
 
      if (//conditin that checks button1wasclicked or not//)
      {
            string d = ifile.IniReadValue("Config Section", "INDENT_NO");
            unscr = Encoding.ASCII.GetBytes("!" + data);
            networkStream.Write(unscr, 0, unscr.Length);
            hash = Encoding.ASCII.GetBytes("#");
            networkStream.Write(hash, 0, hash.Length);
      }
      else
         { return; //this should go in same case to be executes };
 }
 
 
In the above code when control comes in this case first it checks in "if condition" that the above button is clicked or not if not clicked in "else statement control again returns to case and again checks till if contion gets true and when it gets true value it executes code in if and leave and break case." 
 
 
 

Answers (4)
Next Recommended Forum