c#从DataGrid到Mail的值

问题描述:

大家好,



我有一个带数据绑定的datagridview。现在我有一个Funktion来发送邮件。

当邮件表格打开时,我将每个cell.value复制到一个字符串列表中。

将字符串格式化为我的richtextbox (mailform),我插入标签\t。

现在邮件在我的表单中看起来不错,但是如果我发送邮件,那么形成

的文本真的很难看。现在我问是否有另一种更好的方式

来格式化我的文本?



这是将单元格值插入我的代码list:

hi guys,

i have a datagridview with a databinding. Now i have a Funktion to send mails.
when the mailform opens, im copying each cell.value into a list of strings.
to Format the strings right into my richtextbox (mailform), i insert "Tabs" \t.
Now the mail Looks good in my form, but if i send the mail, the Formation
of the text is truely ugly. Now im asking if there is another, better way
to Format my text?

Here is the code for inserting the cell values into my list:

for (int rowcounter = 0; rowcounter < nV_AUFPDataGridView.Rows.Count - 1; rowcounter++)
{
CellsInRow = nV_AUFPDataGridView.Rows[rowcounter].Cells.Count - 1;

for (int cellcounter = 0; cellcounter < nV_AUFPDataGridView.Rows[rowcounter].Cells.Count; cellcounter++)
{
	string Text = "";
		if (nV_AUFPDataGridView[cellcounter, rowcounter].Value == null)
		{
		Text = "0%\t";
		_MailSetUp.AufpData.Add(Text);
		continue;
		}

		if (cellcounter != 2)
		{
		Text = nV_AUFPDataGridView[cellcounter, rowcounter]
                        .Value.ToString() + "\t";
		}
		else
	        {
		Text = nV_AUFPDataGridView[cellcounter,rowcounter]
                        .FormattedValue.ToString();
	        }


		if (cellcounter == 0)
		{
		continue;
		}
		if (cellcounter == 2 || cellcounter == 5 || cellcounter == 7)
		{
		    if (cellcounter == 5 || cellcounter == 7)
		    {
		      Text = Text + "€";
		    }

		  Text = Text + "\t";
		}

		if (cellcounter == CellsInRow)
		{
		  Text = Text + "\r\n";
		}

		_MailSetUp.AufpData.Add(Text);
		}
								}





谢谢



迎接Niko



Thank you

Greets Niko

你好..



你能发一些代码来说明你做了什么?

我建议你的表格中有一个CSS类,它应该适用于这些值,比如填充,边框,颜色和东西...



-Regards
Hi..

Can you post some code as to what you have done?
I would suggest to have a CSS class in your form which should apply to the values, such as padding, border, color and stuffs...

-Regards