ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Transfer record from one form to another if quantity greater than one using C# in Windows Forms Application<p>Hi <a class="username" rel="shabzo"> shabzo</a>,</p> <p>I have created a sample which full fill your requirement you need to modify the code according to your need.</p> <p>Refer below sample code.</p> <p><strong><span style="text-decoration: underline;">Form1.cs</span></strong> </p> <pre class="brush: csharp">DataTable dt = new DataTable(); public Form1() { InitializeComponent(); BindDataGrid(); } public void BindDataGrid() { this.dataGridView1.DataSource = null; this.dataGridView1.Columns.Clear(); this.dataGridView1.ColumnCount = 7; this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.Columns[0].Name = &#34;ProdCode&#34;; this.dataGridView1.Columns[0].HeaderText = &#34;ProdCode&#34;; this.dataGridView1.Columns[0].DataPropertyName = &#34;ProdCode&#34;; this.dataGridView1.Columns[0].Width = 100; this.dataGridView1.Columns[1].HeaderText = &#34;Product&#34;; this.dataGridView1.Columns[1].Name = &#34;Product&#34;; this.dataGridView1.Columns[1].DataPropertyName = &#34;Product&#34;; this.dataGridView1.Columns[1].Width = 160; this.dataGridView1.Columns[2].HeaderText = &#34;t1&#34;; this.dataGridView1.Columns[2].Name = &#34;t1&#34;; this.dataGridView1.Columns[2].DataPropertyName = &#34;t1&#34;; this.dataGridView1.Columns[2].Width = 1; this.dataGridView1.Columns[2].Visible = false; this.dataGridView1.Columns[3].HeaderText = &#34;Pack&#34;; this.dataGridView1.Columns[3].Name = &#34;Pack&#34;; this.dataGridView1.Columns[3].DataPropertyName = &#34;Pack&#34;; this.dataGridView1.Columns[3].Width = 50; this.dataGridView1.Columns[4].HeaderText = &#34;t2&#34;; this.dataGridView1.Columns[4].Name = &#34;t2&#34;; this.dataGridView1.Columns[4].DataPropertyName = &#34;t2&#34;; this.dataGridView1.Columns[4].Width = 1; this.dataGridView1.Columns[4].Visible = false; this.dataGridView1.Columns[5].Name = &#34;Qty&#34;; this.dataGridView1.Columns[5].HeaderText = &#34;Qty&#34;; this.dataGridView1.Columns[5].DataPropertyName = &#34;Qty&#34;; this.dataGridView1.Columns[5].Width = 50; this.dataGridView1.Columns[6].Name = &#34;WSale&#34;; this.dataGridView1.Columns[6].HeaderText = &#34;WSale&#34;; this.dataGridView1.Columns[6].DataPropertyName = &#34;WSale&#34;; this.dataGridView1.Columns[6].Width = 58; this.dataGridView1.Columns[6].DefaultCellStyle.Format = &#34;0.00##&#34;; dt.Columns.AddRange(new DataColumn[] { new DataColumn(&#34;ProdCode&#34;) ,new DataColumn(&#34;Product&#34;) ,new DataColumn(&#34;t1&#34;) ,new DataColumn(&#34;Pack&#34;) ,new DataColumn(&#34;t2&#34;) ,new DataColumn(&#34;Qty&#34;) ,new DataColumn(&#34;WSale&#34;) }); dt.Rows.Add(&#34;ProdCode 1&#34;, &#34;Product 1&#34;, &#34;t1 1&#34;, &#34;Pack 1&#34;, &#34;t2 1&#34;, 1, &#34;WSale 1&#34;); dt.Rows.Add(&#34;ProdCode 2&#34;, &#34;Product 2&#34;, &#34;t1 2&#34;, &#34;Pack 2&#34;, &#34;t2 2&#34;, 0, &#34;WSale 2&#34;); dt.Rows.Add(&#34;ProdCode 3&#34;, &#34;Product 3&#34;, &#34;t1 3&#34;, &#34;Pack 3&#34;, &#34;t2 3&#34;, 3, &#34;WSale 3&#34;); dt.Rows.Add(&#34;ProdCode 4&#34;, &#34;Product 4&#34;, &#34;t1 4&#34;, &#34;Pack 4&#34;, &#34;t2 4&#34;, 0, &#34;WSale 4&#34;); dt.Rows.Add(&#34;ProdCode 5&#34;, &#34;Product 5&#34;, &#34;t1 5&#34;, &#34;Pack 5&#34;, &#34;t2 5&#34;, 5, &#34;WSale 5&#34;); this.dataGridView1.DataSource = dt; } private void button1_Click(object sender, EventArgs e) { DataView dw = new DataView(dt); string[] cols = { &#34;ProdCode&#34;, &#34;Product&#34;, &#34;t1&#34;, &#34;t2&#34;, &#34;Pack&#34;, &#34;Qty&#34;, &#34;WSale&#34; }; DataTable dt1 = dw.ToTable(true, cols); DataTable filtereRecord = (from DataRow dr in dt1.Rows where dr[&#34;Qty&#34;].ToString() != &#34;0&#34; select dr).CopyToDataTable(); if (filtereRecord.Rows.Count &gt; 0) { Form2 f = new Form2(filtereRecord); f.ShowDialog(); } else { MessageBox.Show(&#34;Select atleast one record&#34;); } }</pre> <p><strong><span style="text-decoration: underline;">Form2.cs</span></strong></p> <pre class="brush: csharp">public Form2(DataTable dt) { InitializeComponent(); this.dataGridView1.DataSource = dt; }</pre> <p><strong><span style="text-decoration: underline;">ScreenShot</span></strong></p> <p><strong><span style="text-decoration: underline;"><img src="https://i.imgur.com/OE1Nsuh.gif" alt="" width="544" height="292" /></span></strong></p> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/981307/Transfer-record-from-one-form-to-another-if-quantity-greater-than-one-using-C-in-Windows-Forms-Application/https://www.aspforums.net:443/Threads/981307/Transfer-record-from-one-form-to-another-if-quantity-greater-than-one-using-C-in-Windows-Forms-Application/Mon, 09 Oct 2017 03:49:16 GMT