Rose Rouge

Rose Rouge

  • NA
  • 27
  • 8.4k

Change Value of Cell of DataGridView

Jun 24 2016 5:28 AM
I have 2 forms:
  1.  Form1 contains DataGridView.
  2.  Form2  contains Textboxes, radioButton and Button.
When I select  DataGridView Row it will show me Form2 and Displayed their values in TextBoxs . Every Thing seems better just now.
What I want know is after displaying datas in textboxes , I check the RadioButton then click in the button it will return to Form1 of The selected Row and Change The value of Cell 5.
Here there is My code:
Form1 
  1. private void dataGridView1_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)  
  2.        {  
  3.            DataGridViewCell cell = null;  
  4.            foreach (DataGridViewCell selectedCell in dataGridView1.SelectedCells)  
  5.            {  
  6.                cell = selectedCell;  
  7.                break;  
  8.            }  
  9.            if (cell != null)  
  10.            {  
  11.                DataGridViewRow row = cell.OwningRow;  
  12.                string objet = row.Cells[0].Value.ToString();  
  13.                string objectif = row.Cells[1].Value.ToString();  
  14.                string date = row.Cells[2].Value.ToString();  
  15.                string commentaire = row.Cells[3].Value.ToString();  
  16.                string client = row.Cells[5].Value.ToString();  
  17.                string commercial = row.Cells[6].Value.ToString();  
  18.   
  19.                Détails_RDV détails = new Détails_RDV();  
  20.   
  21.                détails.obj = objet;  
  22.                détails.objectif = objectif;  
  23.                détails.date = date;  
  24.                détails.comm = commentaire;  
  25.                détails.clt = client;  
  26.                détails.commer = commercial;  
  27.   
  28.                détails.Show();  
  29.   
  30.            }  
  31.        }   
 Form2
 
  1. public partial class Détails_RDV : Form  
  2.     {  
  3.         public string obj ;  
  4.         public string objectif;  
  5.         public string date;  
  6.         public string comm;  
  7.         public string clt ;  
  8.         public string commer;  
  9.   
  10.         public Détails_RDV()  
  11.         {  
  12.             InitializeComponent();  
  13.             
  14.         }  
  15.   
  16.         private void Détails_RDV_Load(object sender, EventArgs e)  
  17.         {  
  18.   
  19.             txtObjet.Text = obj;  
  20.             txtObjectif.Text = objectif;  
  21.             txtDate.Text = date;  
  22.             txtCommerci.Text = commer;  
  23.             txtClient.Text = clt;  
  24.             txtCommentaire.Text = comm;  
  25.         }  
  26.   
  27.         private void btnValider_Click(object sender, EventArgs e)  
  28.         {  
  29.             if (radBtnEffectue.Checked == true)  
  30.             {  
  31.                //What should I write here??
  32.             }  
  33.         }  
 
How Can I do That ?

Please help, Thanks in Advance 

Answers (4)