I really hope – this is my lastComplicated question about DGVs.
One bigDGV (about 60 columns), and one smallDGV (about 30 columns).
On bigDGV I select multiple consecutive cells in a row (for example – firstRow).
First, I need to establish the Cell with the highest ColumnIndex (among SelectedCells).
From that point (highestColumnIndex + 1) – to the end of row - I need to create a list/array of cellValues, and keep it in memory for later use, because the bigDGV will change very soon.
At a certain moment (byButtonClick), the correspondingRow of smallDGV(in this case – firstRow) should be populated by the stored list/array - and not from the first - but from the second cell starting.
If nobody has nerves for questions like this – I will understand.

VulpesPosted Jun 5, 2012, 9:06 AM
MementoPosted Jun 5, 2012, 11:54 AM
When I started reading your code, after the first lines I thought:
- Could I maybe, send it as a Message - to Cosmic Beings?
And - I tried:
- I created a button
- Link the code with the buttonClickEvent
- And - Clicked !
The bulbs in myRoom - started Blinking ...
Some unclear pictures appeared on my TV ...
I thought - something is wrong - beacuse (as you say) theCode is not properlyTested,
But, suddenly - i noticed - in myProject -smallDGV was populated Correctly.
Never Mind. I will create some attentionAllert to EndUsers.
MementoPosted Jun 5, 2012, 11:52 AM
Thanks a Lot for your Effort, especialy for attached example. it answers not just my asked question.
I'm pretty sure, one of the best way to learn a language is to read some working codeLines.
Question for thousand of dollars: Why are Indian Programmers - theBestProgrammers ?
AnyWay - ThanksAgain.
Datta KharadPosted Jun 5, 2012, 7:53 AM
Try below example.....or you can refer attachment.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DataGridview_SelectedCell
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private Dictionary
private DataTable dtFilterData = null;
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.Columns.Add("ID","ID");
dataGridView1.Columns.Add("NAME","NAME");
dataGridView1.Columns.Add("SURNAME","SURNAME");
dataGridView1.Columns.Add("JOB","JOB");
dataGridView1.Columns.Add("SALARY","SALARY");
dataGridView1.Columns.Add("ADDRESS","ADDRESS");
dataGridView1.Rows.Add(1);
dataGridView1.Rows[0].Cells[0].Value = "22";
dataGridView1.Rows[0].Cells[1].Value = "DFGF";
dataGridView1.Rows[0].Cells[2].Value = "DFDSD";
dataGridView1.Rows[0].Cells[3].Value = "GDFDSF";
dataGridView1.Rows[0].Cells[4].Value = "45500";
dataGridView1.Rows[0].Cells[5].Value = "PUNE";
dataGridView1.Rows.Add(2);
dataGridView1.Rows[1].Cells[0].Value = "11";
dataGridView1.Rows[1].Cells[1].Value = "ABC";
dataGridView1.Rows[1].Cells[2].Value = "XYS";
dataGridView1.Rows[1].Cells[3].Value = "PQR";
dataGridView1.Rows[1].Cells[4].Value = "1100";
dataGridView1.Rows[1].Cells[5].Value = "MUMBAI";
dataGridView1.Rows.Add(3);
dataGridView1.Rows[2].Cells[0].Value = "33";
dataGridView1.Rows[2].Cells[1].Value = "ERERE";
dataGridView1.Rows[2].Cells[2].Value = "TYTYT";
dataGridView1.Rows[2].Cells[3].Value = "VBVBV";
dataGridView1.Rows[2].Cells[4].Value = "7888";
dataGridView1.Rows[2].Cells[5].Value = "BANGALORE";
dSelectedCell = new Dictionary
dtFilterData = new DataTable();
dtFilterData.Columns.Add("ID", typeof(int));
dtFilterData.Columns.Add("NAME", typeof(string));
dtFilterData.Columns.Add("SURNAME", typeof(string));
dtFilterData.Columns.Add("JOB", typeof(string));
dtFilterData.Columns.Add("SALARY", typeof(int));
dtFilterData.Columns.Add("ADDRESS", typeof(string));
}
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
if (dSelectedCell != null)
{
dSelectedCell.Add((int)dataGridView1.CurrentCell.ColumnIndex, (int)dataGridView1.CurrentRow.Index);
}
}
private void button1_Click(object sender, EventArgs e)
{
var maxKey = dSelectedCell.Max(x => x.Key);
int iRowIndex=dSelectedCell[maxKey];
DataRow dr=null;
dr = dtFilterData.NewRow();
for (int i = maxKey; i < dataGridView1.Rows.Count-1; i++)
{
object OBJ= dataGridView1.Rows[iRowIndex].Cells[maxKey].Value.ToString();
dr[maxKey] = dataGridView1.Rows[iRowIndex].Cells[maxKey].Value;
maxKey++;
}
dtFilterData.Rows.Add(dr);
dataGridView2.DataSource = dtFilterData;
dSelectedCell.Clear();
}
}
}