Click here to Skip to main content
15,922,696 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Is Their any Way to get the Datagridview selected Column index as well as column values to the rich text box with same allignment.Please suggest me
Kornfeld Eliyahu Peter 15-Mar-15 2:16am    
Probably there is, but what have you tried?[^]
Mallesh Shantagiri 15-Mar-15 3:32am    
I am Getting Selected columns index name With addition of "#",after that i am splitting each,here is the code.

public void textboxcontents(string hashedstring)
string[] unhash = hashedstring.Split('#');
// List<string>datas =new List<string>();
string te="";
ArrayList indexes = new ArrayList();
foreach (string s in unhash)
te = te +"\t"+ s+"\t";
int idx = getColumnIndex(s, dataGridView1.Columns);
if (idx != -1)

richTextBox1.AppendText("\t" + "My-Reports" + "\n" + "\n");
richTextBox1.Text = richTextBox1.Text + te + Environment.NewLine;
string data = string.Empty;
foreach (DataGridViewRow row in dataGridView1.Rows)
foreach (int idx in indexes)
data = data + String.Format("{0}",row.Cells[idx].Value) + "\t" + "\t";

richTextBox1.AppendText("\t"+ data + "\n");
data = string.Empty;
Sinisa Hajnal 16-Mar-15 3:05am    
Please move this code into the question (there is Improve question link) - this is hard to read. Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900