hi, 1st of all thank you guys again for all of your help.
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

2 Years
Discussion Span
Last Post by kidkardel

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.


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


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.


so uhm like

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

Edited by kidkardel


Use something like this:
This would reprsent the string in the second cell in the first row of your DGV.

Edited by ddanbe: addition


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


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.


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.