Lanka Developers Community

    Lanka Developers

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Shop

    Pass value between two datagridview from two other forms without closing the form

    Front-End Development
    c sharp programming
    1
    1
    493
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • nowferrifkan
      nowferrifkan last edited by nowferrifkan

      //Write this at your first form button click to open the second form

      frmSelectSpecialCodes frm = new frmSelectSpecialCodes();
      frm.ItemCode = dgvCart.SelectedRows[0].Cells[1].Value.ToString(); 
      frm.ShowDialog();
      dgvCart.SelectedRows[0].Cells[10].Value = frm._textBox1.ToString();
      

      // second line - if you want to take any value to second form use this line
      // forth line - the place where you want to assign the value and the value returning from the second form.

      //In second form

      public string _textBox1
             {
                 get { return lblSpcCode.Text.Trim(); } *// the returning value*
             }
      

      //write this code in gridview click event to get the cell value to textbox

      DataGridViewRow dr = dgvSpcCodes.SelectedRows[0];
      lblSpcCode.Text = dr.Cells[0].Value.ToString();
       this.Close();
      

      //Once we click the row on datagridview getting the value of selected cell in to a textbox and returning the value to datagridview which is in form one without closing form one. like this you can pass the values between text boxes or datagridview to text box.

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post

      0
      Online

      3.7k
      Users

      1.3k
      Topics

      5.3k
      Posts

      • Privacy
      • Terms & Conditions
      • Donate

      © Copyrights and All right reserved Lanka Developers Community

      Powered by Axis Technologies (PVT) Ltd

      Made with in Sri Lanka

      | |