|
Well, in one sense all objects used for DataBinding are in memory. So for anyone to be able to give a meaningful answer I think you are going to have to give a better description of what you are trying to do.
If possible, include a small snippet of the code you have and a description of any errors etc.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
Why do programmers often confuse Halloween and Christmas?
Because 31 Oct = 25 Dec.
|
|
|
|
|
what is the object you are referring to. Is it a dataset?
Jack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
Hi,
I have the following complex type,
public class record()
{
string name1;
string name2;
}
I create a list of records in another function
public list<record> records();//list of records
Now I have to sort this class first by name1 and then by name2. Is there any simple way to do this?
Jack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
Write a comparer that does what you want and use Sort?
|
|
|
|
|
using System.Linq;
public class record
{
public string name1;
public string name2;
}
List<record> records = new List<record>();
records.Add(new record() { name1 = "a", name2 = "b" });
records.Add(new record() { name1 = "c", name2 = "d" });
records.Add(new record() { name1 = "e", name2 = "f" });
records.Add(new record() { name1 = "g", name2 = "h" });
records.Add(new record() { name1 = "i", name2 = "j" });
var r = records.OrderByDescending(sort => sort.name1).OrderBy(sort2 => sort2.name2);;
|
|
|
|
|
rvdenden wrote: var r = records.OrderByDescending(sort => sort.name1).OrderBy(sort2 => sort2.name2);;
This isn't correct.Because IOrderedEnumerable<telement> inherits from IEnumerable<t>, you can call OrderBy or OrderByDescending on the results of a call to OrderBy, OrderByDescending, ThenBy or ThenByDescending. Doing this introduces a new primary ordering that ignores the previously established ordering.
You need to use ThenBy[^] for the second stage of the sort.
var r = records.OrderByDescending(sort => sort.name1).ThenBy(sort2 => sort2.name2);
Simon
|
|
|
|
|
There are lots of ways of sorting the list: see here[^].
I would suggest you implement the IComparable<T>[^] interface and provide an appropriate body for CompareTo method. You can find such an example here[^].
Ramkithepower wrote: Now I have to sort this class first by name1 and then by name2.
In this case a possible implementation of the CompareTo method could be:
public int CompareTo(Record other)
{
int res = name1.CompareTo(other.name1);
if(res == 0)
res = name2.CompareTo(other.name2);
return res;
}
|
|
|
|
|
You can use OrderBy[^]
var sortedData = records.OrderBy(r => r.name1 + r.name2); You just concatenate the names in the key selector to achieve the ordering you want.
Opps. PIEBALDconsult[^] is of course totally right. That was a very stupid suggestion of mine, I don't know what I was thinking. Please ignore the above suggestion.
This is how you should really do it (using ThenBy[^]):
var sortedData = records.OrderBy(sort => sort.name1).ThenBy(sort2 => sort2.name2);
Simon
|
|
|
|
|
I don't think that's reliable.
|
|
|
|
|
|
Unless you right-pad name1. Or are you counting on case-sensitivity?
|
|
|
|
|
Ohh...
You are very right.
Thanks. Will edit.
Simon
|
|
|
|
|
because it is wrong. consider the following set of string pairs:
a,bd
ab,c
and try sorting them the right way and the concatenated way.
It would be right if you were to use string1 + charMax + string2 where charMax is a character that sorts last in the character collection.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Suppose name1 is the empty string..?
edit: ok you changed it
modified on Thursday, May 27, 2010 9:47 AM
|
|
|
|
|
Thank you all for the reply.
Jack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
This article[^] covers the regular ways of sorting; it should be easy to understand and offer good performance at the same time; it does not offer the latest LINQ fancy things.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
How can I get event action (especially mouse events) on windows form use another program?
For example; User darw rectangle on form use with "Program1". Another program (may be windows service) detect user action in "Program1".
Main problem is "Program1" and other program (windows service) in different application domain.
How can I get event from another program?
Thanks...
|
|
|
|
|
One would need to tell the other.
|
|
|
|
|
There is no communication between the two processes. Your service code will never know the user did anything in the other application. Hooking the message pump of another application and interpreting what the user sees and is doing with the mouse is VERY complicated and is, depending on your skill level, going to be prone to failures.
I know, you asked about events. "Events", in the method that you're probably thinking of using, do not cross process boundries. There is no way for a message pump in one application to raise an event in another app.
The application that the user is clicking around in would have to handle it's own, for example, Click event, then setup and make an interprocess call to your service, or, just send the service process a message over some communication line you've setup in both applications.
The best option would be, if you wrote both applications, to setup a communication system between the two apps so the application the user is using can tell the service what's going on and what the user is doing.
It is always far easier, and more reliable, for an application to tell another one what it is doing than it is for an application to try and figure out what is going on in another application by "watching" it.
|
|
|
|
|
Yeah, that's what I said.
|
|
|
|
|
Hello,
I am using that code snippet to print a word document out of my application.
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = @"c:\test.doc";
startInfo.Verb = "printto";
startInfo.Arguments = strPrinterName;
startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.UseShellExecute = true;
startInfo.ErrorDialog = true;
System.Diagnostics.Process.Start(startInfo);
It works fine but:
The Problem is, that word pops up, print and quit.
Is there an additional parameter to set, to tell word to do it in hidden mode like requested
startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
to print silently in the backgound ?
Thanks Frank
|
|
|
|
|
Hi Experts
i am working in Winform using VS 2005 and SQL Server 2005 in C#.NET.
i have a project which have import data from Excel Sheet.
but the data in Excel sheet is very Large Scale like 350000 Record.
Then it take time to import the data from excel sheet.
then can you suggest me how to Imports Such type of Bulk data .
Thank u
Dinesh
|
|
|
|
|
Did you search on the internet for a solution?
I did and found this.
My signature "sucks" today
|
|
|
|
|
But i want to import Bulk data in Lacks and if i want to paging
apply on importing data then have you any idea how i apply paging in
import data in select Query.
Thank u
|
|
|
|
|
Use DTS or SSIS transformation. It generally finishes the work in seconds. Build is easy too.
Jack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|