473,396 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

reverse order in string writer

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
Dec 16 '06 #1
1 1985
It seems to me you AppendFormat [3] first befor [1] and [2].Does that method
to you? I don't know what happen to your [0] anyway.

chanmm

"Doug" <go**********@optusnet.com.auwrote in message
news:45**********************@news.optusnet.com.au ...
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


Dec 17 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

59
by: Raymond Hettinger | last post by:
Please comment on the new PEP for reverse iteration methods. Basically, the idea looks like this: for i in xrange(10).iter_backwards(): # 9,8,7,6,5,4,3,2,1,0 <do something with i> The...
1
by: Jim P. | last post by:
I have a client server set of apps that can connect through socets and send data back and forth. I'm trying to get it to send XML messages back and both. Currently it works as string data. I...
20
by: sahukar praveen | last post by:
Hello, I have a question. I try to print a ascii file in reverse order( bottom-top). Here is the logic. 1. Go to the botton of the file fseek(). move one character back to avoid the EOF. 2....
8
by: vijay | last post by:
Hello, As the subject suggests, I need to print the string in the reverse order. I made the following program: # include<stdio.h> struct llnode { char *info;
8
by: jamie | last post by:
Here's a class I'm working with public class BatchHeader { public string ScaleSite; public string FromScaleDate;
10
by: aatish19 | last post by:
1: Write a program that asks the user to input an integer value and print it in a reverse order Sample Output Enter any number 65564 Reverse of 65564 is 46556 2: Write a program that takes a...
1
by: Patrick.O.Ige | last post by:
Hi guys, I just moved a project from my pc to a server production (to an ISP). on my pc it all works fine with no errors. After fireing up the first page "default.aspx" i get the error...
2
by: Doug | last post by:
Hi I have a datagridview in a windows C# application and i am allowing a user to select items from the datagridview. I allow the user to copy the selected items to the clipboard and then if...
40
by: KG | last post by:
Could any one tell me how to reverse the bits in an interger?
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.