|
|
I did, it does seem like an overkill since the BindingList has an OrderBy function. I just don't know how yo use it.
|
|
|
|
|
If you want to support sorting, you have to derive your own class from BindingList. This[^] MSDN article explains why you should do that and how. Please read carefully, especially the "BindingList<t>: What's Missing" section.
|
|
|
|
|
riddick_86 wrote: Please read carefully
Well that's an extremely high expectation round here. Reading carefully is also considered overkill by most our members. Magic is preferred, or when not available a copy paste solution will do. 
|
|
|
|
|
Thanks I'll check it out!
|
|
|
|
|
riddick_86 wrote: you have to derive your own class from BindingList
Turns out there was a simple way after all.
listOfObjects = listOfObjects.OrderByDescending(c => c.NameAndSurname).ToList();
That was a list, then I just convert it back to a BindingList.
|
|
|
|
|
Is "listOfObjects" a BindingList to begin with? If it is then you can't use this trick to sort the list as ToList() gives a generic list which cannot be converted to a BindingList, or am I missing something?
Rafique Sheikh
"The truth will set you free but first it will piss you off".
|
|
|
|
|
Rafique Sheikh wrote: Is "listOfObjects" a BindingList to begin with? If it is then you can't use this trick to sort the list as ToList() gives a generic list which cannot be converted to a BindingList, or am I missing something?
Took some digging in our SVN to find that code.
"listOfObjects" is a normal List<>, which I sort as explained in my previous post.
I simply convert it back to a BindingList using a foreach loop, adding each object to the new BindingList one-by-one. I think it has a slight speed penalty, but it works great and I had no better workable solution at the time.
|
|
|
|
|
Thanks for the reply. I see, that's what I thought. Actually the OrderByDesceending and OrderBy, both return an IEnumerableOrdered array which you can iterate over to do the same. I was trying to avoid because of the penalty and also for cleaner code. It is too bad that when you call OrderBy on a BindingList or any other such object the actual list is not ordered but rather you are returned an ordered list. I have the same frustration with this as I have with functions like Remove, Replace for strings etc. Why don't they change the object on which we perform those actions?
Anyway, I think I will have to derive from BindingList<t> and write my own SortableBindingList class!!
Rafique Sheikh
"The truth will set you free but first it will piss you off".
|
|
|
|
|
BindingList<MyClass> b = new BindingList<MyClass>();
b = new BindingList(b.OrderBy( m => m.MyPropertyFromMyClass).ToList()));
|
|
|
|
|
|
hello..
i have to send data i mean collection of5 string variables over the tcp connection using a socket. but the problem is that each time i have to ecode the string to byte and send. can i send all the strings as a collection of bytes or array and decode the sequence at the destination i.e the rciever... thans for any advices.... bye
|
|
|
|
|
Yes, you can use the Encoding.GetBytes[^] method for encoding the strings into bytes,
then you can use Encoding.GetString[^] at the destination to decode the bytes into strings.
Edit: Sorry, I misread your post. What you want to do is to collect all strings, convert them into bytes and send them all at the same time - then decode them at the receiver. Let's say you have an array with the strings - use a StringBuilder and a foreach loop to build the strings into one big string. Remember to apply a seperator after each string:
builder.Append(theString + seperator);
The strings would then come out as (assuming semi-colon ( ; ) is the seperator):
hello;goodbye;hi;
At the receiver application you would then split the string (after decoding it of course) into an array to get each string.
I hope you could understand what I tried to say, otherwise ask.
Kristian Sixhoej
"You can always become better." - Tiger Woods
modified on Wednesday, February 18, 2009 10:37 AM
|
|
|
|
|
that was fine i got it... thank you for the keen interest.... have a gud day..
|
|
|
|
|
You're welcome.
Good day to you as well.
Kristian Sixhoej
"You can always become better." - Tiger Woods
|
|
|
|
|
I have tried to follow a few, including some for here I believe, but I didn't find any explanations on the actual description of the logic of the implementation of the event, delegates and sender objects. Basically I'm looking for something that has both code and theory wrapped in an easy to digest package.
|
|
|
|
|
|
[ShamelessPlug]I've just updated one of mine here[^].
Most of the theory is gradually introduced in logical, practical steps throughout the article, but the real deep stuff/theory is exluded and left to the other articles you've probably already found.[/ShamelessPlug]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
thanks Davey, your tutorial looks fairly accessible to a non-pro such as myself.
I'll print it out fur further reading.
|
|
|
|
|
|
Nice one. Bookmarked.
The word "politics" describes the process so well: "Poli" in Latin meaning "many" and "tics" meaning "bloodsucking creatures."
जय हिंद
|
|
|
|
|
Basically, if I input a text and I query the variable Texbox.Text, for instance, it still stays empty or shows the initial value of the text field. Same with checkboxes, etc.
I was able to fix this issue before, but I can't for my life remember how. I tried form refreshes and updates and reloads.
Thanks!
|
|
|
|
|
Can you maybe show some code where you read the value?
Because if you also make a button and add an onclick event on this one and put a breakpoint there, you can read out the value of the textbox in the immediate window. Should work.
|
|
|
|
|
the problem is, I am developing plugins for an external program. I cannot debug because the plugins (DLLs) are accessed by buttons on the program's graphical interface rather than being mere external commands or macros. Thus I cannot start the application remotely while debugging the code. I have to put message boxes to show me any variables in the code....and those were the values I found.
I used a form reload/refresh command in the subroutine of the event of clicking on a checkbox and that didn't actually update the content of the 'checked' variable.
|
|
|
|
|
If you reload your form, the data will be set to default. Maybe try using Threads and update the textboxes/ labels every 100 ms.
You can also still try the button and update when you click on the button.
|
|
|
|