I am creating Windows application using c# 2010
I tried to display string value in cell[1] only, but my string value display all cells. How to solve this error any one give me some ideas.
Here I am displaying my code
C#
string test = "2023-24/k-";
string insertValueAs = "\t" + test;
for (int i = 0; i < dGV.RowCount - 1; i++)
{
string stLine = "";
for (int j = 0; j < dGV.Rows[i].Cells.Count; j++)
stLine = stLine.ToString() + Convert.ToString(dGV.Rows[i].Cells[j].Value) + "\t";
stLine = stLine.ToString() + Convert.ToString(dGV.Rows[i].Cells[1].Value) + "\t" + test;
stOutput += stLine + "\r\n";
}
Rajkiran SwainRank #165 · 14.4K reputationPosted May 5, 2023, 11:51 AM EDT
string test = "2023-24/k-"; string insertValueAs = "\t" + test; for (int i = 0; i < dGV.RowCount - 1; i++) { string stLine = ""; // add first cell value stLine = Convert.ToString(dGV.Rows[i].Cells[0].Value) + "\t"; // add string value to second cell stLine += insertValueAs; // add remaining cell values for (int j = 2; j < dGV.Rows[i].Cells.Count; j++) { stLine += Convert.ToString(dGV.Rows[i].Cells[j].Value) + "\t"; } stOutput += stLine + "\r\n"; }Boopal Babu149 reputationPosted May 5, 2023, 11:59 AM EDT
Sir thanks for your code, but out the second cell is coming to empty, here I am attached output screenshot, how to solve this problem.
Boopal Babu149 reputationPosted May 5, 2023, 12:07 PM EDT
Sir i need this type of output.