|
Hi,
I am writing code to reload the last active items and windows of the application, Basically I have 4 windows 2 are datagridview , 1. listview, 1 is tree view, in these 4 windows I can able add data from different files based on user selection. I need to reload all this when the application is restarted. currrently I am writing manually all data into the file and saved the file path location in windows registry, I felt it is very time consuming, and don't now how to improve the timimg, please provide your inputs is there a way to do this job in a simple manner.
SomaShekhar
|
|
|
|
|
It sounds to me that you're on the right track. Saving state is really never easy. What I have done is created a UserPreference class for my apps. This is simply a class the encapsulates a the Dictionary<> object, which is new to .Net 2.0
What I do is init the dictionary like this:
C#: Dictionary<string,> preference = new Dictionary<string,>;
With the "preference" object, you can specify a unique string for the key and use it to store and retrieve as many items as necessary to restore the program state. This code model is not as messy but you will always have to do some "manual labor"!
Cheers,
Richard
I've used up all my sick days, so today I'm calling in dead.
|
|
|
|
|
Hi Richard,
Thanks for your reply, I am not still clear, whether do I need to manually write all the forms information? if not could you please provide a code snippet how to avoid the manual updation.
Thanks
SomaShekhar
|
|
|
|
|
If there is any automatic save option, I don't know of it. Even if there was one provided by MS, it would generically store too much data and make the file size too large. For example, you don't want to be storing every attribute of the listView object: Font, BackColor, ForeColor, Items etc.
Here's a generic example to illustrate the preference class:
//Save the form's background color
preferences.Add("windowsBColor", this.BackColor);
--------
//Restore the windows backcolor
if (preferences.ContainsKey("windowBColor"))
{
this.BackColor = (Color)(preferences["windowBColor"]);
}
If you need further assistance, don't hesitate to ask.
Cheers!
Richard
My code this week has no errors. But it's Monday morning and I haven't got out of bed.
|
|
|
|
|
Hi guys, I've written an application in pure C++ and the command line and now I'd like to convert it to Windows.
I am at the very first steps in using Windows Forms and I am wondering if anyone could be kind enough to help.
To simplify the problem, let's suppose my application is composed of 2 input edit text boxes (Box1, Box2), a button (Calculate), and 1 output textbox (Box3). What is the correct code required to display the result of the calculation (Box1+Box2) in the output textbox (Box3)?
I've read 1300 pages of the excellent Ivor Horton's Beginning C++ 2008 book....only to discover that this simple topic is not covered!!
Many thanks
jEDI
|
|
|
|
|
J_E_D_I wrote: I've read 1300 pages of the excellent Ivor Horton's Beginning C++ 2008 book....only to discover that this simple topic is not covered!!
Really?? Somehow, I doubt converting a string to a number wasn't covered. Perhaps the Parse methods of the Int32 struct or the Convert class may help.
|
|
|
|
|
Can we add Listbox control to Datagridview column at run time??
Thankq
|
|
|
|
|
You can add a DropDownList if it helps
|
|
|
|
|
I try to write my own Paint program , and I wonder how to create the "layer system" , like Photoshop , Paint.NET 's features , I try to draw multiple stacked images on form , but it just works terribly .
Anyone got an idea of how to do it ? Thanks ^^
|
|
|
|
|
You may want to take a look at the source code for Paint.Net
The last time I saw it it was open source.
|
|
|
|
|
I got the Paint.Net source code , but without any idea in my mind , reading these codes just waste time and bring headache ^^ , anyone got ideas of how to do this ??
|
|
|
|
|
Having headaches is part of becoming a computer programmer so you might as well get use to it
Go into detail with what you have already attempted as far as layered graphics and the forums might be able to guide you based on the skills that you are showing with what you have tried so far. As you can tell layered graphics can get as complicated as Paint.NET (not to mention Photoshop), or they can be fairly simple. It just matters with how much time you want to put into the application.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
Thomas Stockwell wrote: Having headaches is part of becoming a computer programmer so you might as well get use to it
Thomas Stockwell wrote: It just matters with how much time you want to put into the application.
And how much of a headache you want to put up with...
|
|
|
|
|
Hi All,
I have created VS2008 windows application and Setup project. Now I want to stop Installation process for some specific conditions. I used "Throw New Install Exception", but it shows me strange message. Can any one give me some other solution?
Thanks
Praful U
|
|
|
|
|
I understand the general difficulty of allowing an enumerable class to be modified within an enumerator. Nonetheless, there are times when it would be very useful to go through a dictionary and purge all items meeting some criterion. While it would be possible to produce a list of the keys of the items to be deleted and then iterate through that list, doing so would seem needlessly complex and expensive.
I've searched for messages related to this subject and none that I've found seem to offer a solution except to note the general difficulties of allowing modification to an object within an enumerator.
What would seem most useful would be to have an object that supported an interface similar to iEnumerable but with the addition of a method RemoveAndMoveNext. Use of that method would remove the currently-selected item from the collection and advance to the next one. It would disqualify any other enumerators that exist to the collection, but would do whatever was necessary to maintain its own correct operation.
An alternative would be to have a ConditionalRemove method which would call a function on all items in the collection and remove those for which the function returns true. Such an approach could work well, but could be a nuisance in languages which don't support anonymous delegates.
Are there any free dictionary-style collections that support anything like either of those suggestions?
|
|
|
|
|
Or you could instantiate a new Dictionary, then iterate the existing one, adding the items you do want to the new one.
|
|
|
|
|
That could be done, but it would seem rather wasteful.
In nearly all common practical algorithms for storing collections, support for DeleteAndMoveNext could be added relatively simply. In many cases, it would add no extra work to the iterator's normal operation; in others, it would add a small amount of work (e.g. a singly linked list would need to keep a pointer to the item before the current one). Given the number of tasks that require striking from a collection objects which meet a particular criterion, and given that an iterator will often have information that would facilitate the deletion of an object from a collection, having an extended iEnumerator interface would seem useful.
BTW, for some types of collection, where the enumerator contains all the information about an object (e.g. a KeyValuePair) it may be useful to have general-purpose Add and Delete functions within the enumerator itself. Such functions would invalidate any other enumerators to the root object, but would do whatever was necessary to maintain their own validity. Not sure that would have much added utility beyond DeleteAndMoveNext, though.
|
|
|
|
|
supercat9 wrote: Use of that method would remove the currently-selected item from the collection and
...invalidate the Enumerator all in one shot. As you've found out, you cannot modify a collection during an Enumeration ("for each" operation).
The only solution would be to use in Indexed (for(i=0;i<10;i++) item(i)...) operation, treating the collection as an array instead.
|
|
|
|
|
Dave Kreskowiak wrote: ...invalidate the Enumerator all in one shot. As you've found out, you cannot modify a collection during an Enumeration ("for each" operation).
The whole idea of having an object return an enumerator that supported a DeleteAndMoveNext object would be that such a function would do whatever was necessary to avoid jinxing the enumerator. Note that the DeleteAndMoveNext would not be a general-purpose delete; it could only delete the current object. A simple implementation for an array-based list, if one wanted deletes to be performed immediately, would be to move down all objects above the present object, without bumping the object index. A singly-linked list object whose iterator kept a pointer to the previous object could 'swing' that pointer to point to the object following the present one and then advance the present object (note that this would be much faster than doing a search-and-delete).
An alternative general approach to allow deletions while traversing an iEnumerable object would be to have the 'delete' function mark an item as invalid (using either a 'valid' flag or a sentinel value) and also set a flag in the collection to indicate that one or more deletions had taken place. If 'add' operations are not allowed during an enumeration, the next add operation could check whether any items are marked for deletion (using the collection's flag to start with) and then remove all items that are so marked. For an array-based implementation, this could be much faster than having all deletes performed 'instantly'.
|
|
|
|
|
Hi,
two comments:
1.
I too would like to have a non-resettable enumerator that remains operational when elements
are modified, deleted or new ones inserted at a point that has already been passed.
2.
There is a nice List.RemoveAll() Method that accepts a predicate. That should solve your problem.
|
|
|
|
|
Luc Pattyn wrote: There is a nice List.RemoveAll() Method that accepts a predicate.
Good to know. Unfortunately I need a collection that behaves like a dictionary. Perhaps the best approach would be to have something that's like a dictionary with the addition of RemoveForAll; unfortunately I know no good way to adapt the existing dictionary to fit that need except by having the removeForAll create a list of keys of objects to be deleted, which would likely take time n^2.
|
|
|
|
|
In case of typed dataset I want to pass as an array to the typed dataset so that i can have the all data of selected code in arrays filled in dataset
|
|
|
|
|
Hello,
I have to display HTML in desktop application. Not only a simple text but also images and maybe flash elements and movies... Problem is because the background is an image and the browser background must be transparent.
I tried several solutions but all of them failed...
Have You ever had the same problem or do You konw any solution? It may be even payable .NET control.
|
|
|
|
|
I've never seen, nor heard of, a browser control that is transparent to the form. I think you're going to have to write this one yourself.
|
|
|
|
|
I was really affraid to hear that there is not such component...
I've got idea how to write transparent browser, but I'm concerned about "blinking" effect... GDI+ is not a speed demon...
|
|
|
|