Adam azhari

Adam azhari

  • 1.9k
  • 12
  • 175

How to filter Datagridview From Another Datagridview c#

May 31 2020 5:32 PM

I am looking for a way to filter Datagridview to another Datagridview and by using a reference number in the first column and searching for a sum of the values of this reference number in another column

Look at the pictures below to understand what I'm looking for:

Datagridview 1

 
 

For datagridview 1 in doesn't have any data table or database just get data from some text boxes

Datagridview 2

 

For datagridView 2 i Just filled it manually, So i want to do it automatically.

can someone help me..? thanks.

sorry for my bad english.

This is my code
  1. namespace SAMPLE    
  2. {    
  3.     public partial class Form2 : Form    
  4.     {    
  5.         public Form2()    
  6.         {    
  7.             InitializeComponent();    
  8.         }  
  9.         private void add_Click(object sender, EventArgs e)    
  10.         {             
  11.             int n = dataGridView1.Rows.Add();           
  12.             dataGridView1.Rows[n].Cells[0].Value = txtReff.Text;    
  13.             dataGridView1.Rows[n].Cells[1].Value = txtProd.Text;    
  14.             dataGridView1.Rows[n].Cells[2].Value = textPrice.Text;    
  15.             dataGridView1.Rows[n].Cells[3].Value = txtNumber.Text;    
  16.             dataGridView1.Rows[n].Cells[4].Value = txtSum.Text;      
  17.         }  
  18.         private void textHt_TextChanged(object sender, EventArgs e)    
  19.         {    
  20.             try    
  21.             {  
  22.                 txtSum.Text = (double.Parse(textPrice.Text) * double.Parse(txtNumber.Text)).ToString();   
  23.             }    
  24.             catch    
  25.             {    
  26.             }  
  27.         }   
  28.         private void txtFrs_TextChanged(object sender, EventArgs e)    
  29.         {    
  30.             try    
  31.             {  
  32.                 txtSum.Text = (double.Parse(textPrice.Text) * double.Parse(txtNumber.Text)).ToString();    
  33.             }    
  34.             catch    
  35.             {    
  36.             }   
  37.         }          
  38.     }    
  39. }  
 

Brought to you by: JavaScript SDK for Bold BI dashboard and analytics embedding. Free trial.

Answers (1)