D
Doug
Hi
I have a datagrid view that I have enabled a use to copy data from. However
the copy seems to work in reverse.
This results in the last value selected being the first copied to the
clipboard, but I require the data copied to be in the order in the
datagridview.
Is this something I should attend to within the string writer or is there a
simple thing that I am missing here??
foreach (DataGridViewRow row in dgMainView.SelectedRows)
{
sb.AppendFormat("{0},", row.Cells[3].Value);
sb.AppendFormat(" /* {0} - Wave {1} */", row.Cells[1].Value,
row.Cells[2].Value);
sb.Append(Environment.NewLine);
}
if (counter != "0")
{
Clipboard.SetData(DataFormats.Text, sb.ToString());
// Initializes the variables to pass to the MessageBox.Show method.
string message = counter + " rows copied to clipboard.\nWould you like to
open Notepad\nin order to paste these items?";
string caption = "Clipboard";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
MessageBoxIcon icons = MessageBoxIcon.Information;
// Displays the MessageBox.
DialogResult OpenNotePad;
OpenNotePad = MessageBox.Show(this, message, caption, buttons, icons);
if (OpenNotePad == DialogResult.Yes)
{
string file = Path.GetTempFileName();
StreamWriter sw = new StreamWriter(file);
sw.Write(sb.ToString());
sw.Close();
thanks
Doug
I have a datagrid view that I have enabled a use to copy data from. However
the copy seems to work in reverse.
This results in the last value selected being the first copied to the
clipboard, but I require the data copied to be in the order in the
datagridview.
Is this something I should attend to within the string writer or is there a
simple thing that I am missing here??
foreach (DataGridViewRow row in dgMainView.SelectedRows)
{
sb.AppendFormat("{0},", row.Cells[3].Value);
sb.AppendFormat(" /* {0} - Wave {1} */", row.Cells[1].Value,
row.Cells[2].Value);
sb.Append(Environment.NewLine);
}
if (counter != "0")
{
Clipboard.SetData(DataFormats.Text, sb.ToString());
// Initializes the variables to pass to the MessageBox.Show method.
string message = counter + " rows copied to clipboard.\nWould you like to
open Notepad\nin order to paste these items?";
string caption = "Clipboard";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
MessageBoxIcon icons = MessageBoxIcon.Information;
// Displays the MessageBox.
DialogResult OpenNotePad;
OpenNotePad = MessageBox.Show(this, message, caption, buttons, icons);
if (OpenNotePad == DialogResult.Yes)
{
string file = Path.GetTempFileName();
StreamWriter sw = new StreamWriter(file);
sw.Write(sb.ToString());
sw.Close();
thanks
Doug