I recently started my project for a personal app.
I have a DataGridView (bit of searching told this suites more good to my app), called ms_trans.
What I want to do with it, to load into a for cycle, and GET ALL ROW into a method.
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
string srt = "";
for (int i = 0; i >= ms_trans.Rows.Count; i++)
{
not_mess.Text += (string)ms_trans.Rows[i].Cells[1].Value;
This is my for cycle. The problem is, I don't know why it gaves me 0 values. (I'm not stupid, I entered values all the time). When I specified whic row and column value I want to get it gave back values properly.
Is it the string appending causing null values? Or what? I'm really stucked here.
PS.: I want to save the rows into a *.txt file, but even if I can't get the values. ONLY *.txt FILE IS ACCEPTABLE! Just help me out with getting values....
You can try the Foreach loop, that suppose to garantee you itterate through all the rows:
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
string srt = "";
foreach (GridViewRow row in ms_trans.Rows)
{
not_mess.Text += (string)row.Cells[1].Value;
}
}
hope it'll help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.