This is the article about how to transfer row of one DataGrid to another DataGrid one by one on double click event of an DataGrid. How You will do it. This coding will explain you .
For this application you need two DataGrid and two Command Button
First button Name is Submit Button
Second Button Name is Exit Button.
Second grid Name is da_SpecifiedGrid.
------------------Code-----------------------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Reflection;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace WindowsApplication3
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class FrmPractice : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.Button btn_Click;
private System.Windows.Forms.DataGrid da_SpecificRecords;
private System.Data.DataTable dtSecondGrid = new System.Data.DataTable();
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Button btn_Exit;
public FrmPractice()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.btn_Click = new System.Windows.Forms.Button();
this.da_SpecificRecords = new System.Windows.Forms.DataGrid();
this.btn_Exit = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.da_SpecificRecords)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(32, 48);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(440, 152);
this.dataGrid1.TabIndex = 0;
this.dataGrid1.DoubleClick += new System.EventHandler(this.dataGrid1_DoubleClick);
this.dataGrid1.Navigate += new System.Windows.Forms.NavigateEventHandler(this.dataGrid1_Navigate);
//
// btn_Click
//
this.btn_Click.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(192)), ((System.Byte)(128)));
this.btn_Click.Location = new System.Drawing.Point(48, 224);
this.btn_Click.Name = "btn_Click";
this.btn_Click.Size = new System.Drawing.Size(96, 23);
Join the conversation! Your thoughts help the community grow.