I have two datagrid's in one form,so when i click by using cellclick event it shows the selected row of first datagrid in the second datagrid,so my question is how to increment it with the previous selected row of first datagrid,as i select other row the first selected row disappears??
Taufique111 0 Newbie Poster
Recommended Answers
Jump to PostCould you post the code of your CellClick event handler?
Jump to PostIt would be easier to understand what you are trying to do if you post screen shots from the program. As an alternative, you could create tables in Word/Wordpad that represent the two datagridviews and post those-describing what you desire to accomplish.
Jump to PostPut this
List<object> destList = new List<object>();
outside of your method. You are creating a new list every time you click and then add just one element to it.
Jump to PostI tried this code, and it seems to work:
private void DGV1_CellClick(object sender, DataGridViewCellEventArgs e) { foreach (DataGridViewRow row in DGV1.SelectedRows) { int index = DGV2.Rows.Add(row.Clone()); foreach (DataGridViewCell cell in row.Cells) { DGV2.Rows[index].Cells[cell.ColumnIndex].Value = cell.Value; } } }
All 16 Replies
ddanbe 2,724 Professional Procrastinator Featured Poster
Taufique111 0 Newbie Poster
Taufique111 0 Newbie Poster
ChrisHunter 152 Posting Whiz in Training Featured Poster
cgeier 187 Junior Poster
Taufique111 0 Newbie Poster
ddanbe 2,724 Professional Procrastinator Featured Poster
Taufique111 0 Newbie Poster
ddanbe 2,724 Professional Procrastinator Featured Poster
Taufique111 0 Newbie Poster
ddanbe 2,724 Professional Procrastinator Featured Poster
Taufique111 0 Newbie Poster
ddanbe 2,724 Professional Procrastinator Featured Poster
Taufique111 0 Newbie Poster
ddanbe 2,724 Professional Procrastinator Featured Poster
Taufique111 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.