|
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.
|
|
|
|
|
what's the difference between doing a button and just dumping code into the Checkbox clicked event?
|
|
|
|
|
It always works for me.
But there is no difference, I didn't understand you already used a userevent (checkbox clicked). But have you tried not to reload the form, but only reload the data?
|
|
|
|
|
using something like checkbox.update();
?
|
|
|
|
|
No,
You've got some form, this is your outputscreen, the way you debug, right?
So let's say you have one label named outputLabel and one checkbox.
When you initialize, you will probably do something like this:
public Form()
{
InitializeComponents();
outputLabel.Text = getDataFromDatabase();
}
and then something happens and the values changes, but you won't see those values, because you didn't update your form.
So in your case you will do something like this:
public void checkBox_Clicked(object sender, EventArgs e)
{
Form.Reload();
}
but in stead of this, you have to only refresh the values in the textboxes/labels. Something like this:
public void checkBox_Clicked(object sender, EventArgs e)
{
outputLabel.Text = getDataFromDatabase();
}
that's all. If it is something else, you should place some code of the eventhandling.
|
|
|
|
|
|
well I couldn't find a command called getfromdatabase.
Did you mean I would have to create my own subroutine and storage variable?
I did that for a checkbox, so now when the checkbox is changed a static boolean variable is swithced. That works for checkboxes, but implementing it for textboxes for instance might prove cumbersome.
|
|
|
|
|
No, all I did was asuming. I asumed you would get data from a 'place' and that 'place' would be getFromDatabase().
But to recap, to clear that I understand your problem well:
You have a form which you create and can own
You have a process running on a computer
This process will change some stuff and you want to get those on your form for debugging.
To refresh, you are using a checkbox with an OnChanged event?
But when you click on the checkbox, nothing happens.
Is this correct?
If it is, please send the code which is inside the OnChanged event. Then I can maybe see the problem.
If there is no code inside this event, then I would suggest you to call a function which will place the values you would like to see/debug, on your screen.
|
|
|
|