0

hi, 1st of all thank you guys again for all of your help.
a3ce81a2808d02214775965e56a6d32b
i have this datagrid view and i want to write it on a richtextbox like:

14       APPLE0-13       @ 60.00       840.00

so on and so forth.
how can i achieved getting all of them and can i also ask how do you space them?what is padding?do i use padding?how to use padding?

I really appriciate it guys i can only say thank you for the help you are giving me.

btw does foreach come in play with my question?

thank you, arigato, salamat, gracias

3
Contributors
8
Replies
32
Views
2 Years
Discussion Span
Last Post by kidkardel
Featured Replies
  • 1
    ddanbe 2,525   2 Years Ago

    You could use an equidistant font, examples [here](http://en.wikipedia.org/wiki/Samples_of_monospaced_typefaces). Now use "empty" strings(filled with say 20 spaces) and use the [CoptyTo method](http://msdn.microsoft.com/en-us/library/system.string.copyto(v=vs.110).aspx) from the string clas, to position the info from the DataGridView in this space filled string. Append these strings now to the RichTextBox. Success. Read More

  • 1

    Use for loop through DGV's rows and a nested for loop through DGV's columns Every time add a new line after completion of nested loop for column. Read More

  • 1
    ddanbe 2,525   2 Years Ago

    Use something like this: `Datagridview1.Rows[0].Cells[1].Value` This would reprsent the string in the second cell in the first row of your DGV. Read More

  • 1
    ddanbe 2,525   2 Years Ago

    Your for loop should look like this: `for (int i = 0; i < dgv.RowCount - 1; i++)` DGV has depending on the settings a row extra. Row and columns start at zero. Read More

1

You could use an equidistant font, examples here.
Now use "empty" strings(filled with say 20 spaces) and use the CoptyTo method from the string clas, to position the info from the DataGridView in this space filled string.
Append these strings now to the RichTextBox.
Success.

0

Tnx......
but uhm how can i get the strings from the datagridview to richtextbox :
example i have x numbers of row for datagridview with 4 number of columns. how can i put the datas line per line until i have exhausted all of my datagridview rows

Edited by kidkardel: not thinking straight

1

Use for loop through DGV's rows and a nested for loop through DGV's columns
Every time add a new line after completion of nested loop for column.

0

so uhm like

foreach (Datarows p in Datagridview1)
{
\\transfer 
}
i tried this but foreach gets a red zigzag line it says something about does not contain public definition getenumerator

Edited by kidkardel

1

Use something like this:
Datagridview1.Rows[0].Cells[1].Value
This would reprsent the string in the second cell in the first row of your DGV.

Edited by ddanbe: addition

0

hi , i have tried this.

for (int i = 1; i < dgv.RowCount; i++)
            {
                rtb.Text = rtb.Text+ dgv.Rows[i].Cells[2].Value.ToString();
                    }

but i am getting errors of d6e6d800d6c29042f3078ea6c90f9e71

1

Your for loop should look like this:
for (int i = 0; i < dgv.RowCount - 1; i++)
DGV has depending on the settings a row extra.
Row and columns start at zero.

0

yey tnx mr ddanbe!

really appreciate you help.
yours too mr shark_1

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.