|
In the Solutions Explorer I right clicked on my project's name then went to 'Add', 'Add Existing Item...'.
Next I selected a .bmp image and hit enter.
Does that help?
|
|
|
|
|
wetdog500 wrote:
In the Solutions Explorer I right clicked on my project's name then went to 'Add', 'Add Existing Item...'.
Well, not really. What you did, is just adding a specific bitmap image as a resource into your solution. If all u need is opening a bitmap during runtime and save it somewhere else, you just have to follow the small code sample I provided you with before.. or something similar.
Hope this helps
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Thanks, but what path do I use to access the image?
|
|
|
|
|
Well, that's up to you.
I think that you would want your users to be able to specify the path to a bitmapt for themselves by browsing for a specific file or typing down the filename path for themselves. It wouldn't really made much sense to just specify a fixed filename path in your code right?
A simple example:
You could drop two textboxes and a button on your form. The users would then type a path to a bitmap in the first textbox, the new path to which the bitmap will be copied in the second textbox (if it does exists under that path), and finally press the button to actually copy the bitmap.
On the button click event you could have something like this:
Bitmap myBitmap = new Bitmap(this.textbox1.text);<br />
<br />
myBitmap.Save(this.textbox2.text);
A small tip:
Btw, you would have to provide some checkups. E.g. make sure that the path names the user provided are valid before attempting to load a bitmap. Or, make sure that the user HAS provided paths for both textboxes.
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
No, I'm sorry I didn't explain myself well enough.
I want to have the user copy a resource in my program, not on the hard disk, to a loction on their hard disk.
How do I access that resource?
|
|
|
|
|
wetdog500 wrote:
How do I access that resource?
To programmatically access one of your resources you could say something like:
Assembly myAssembly = GetExecutingAssembly();
Stream resourceStream = myAssembly.GetManifestResourceStream("myBitmap.bmp");
Bitmap image = new Bitmap(resourceStream);
wetdog500 wrote:
I want to have the user copy a resource in my program
I am not sure whether you can do that. Resources are part of your assembly and are included in it every time you compile your program
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
|
It's alright. Glad I could help
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
|
I didn't know you could do that but it makes sense now that I think about it.
"If there is a God, atheism must seem to Him as less of an insult than religion." - Edmond de Goncourt
|
|
|
|
|
It is cool indeed, although I have to assume your example is contrived since just using "3.1415927" would have avoided boxing the numeric value (as well as a call to the member function 'ToString() ').
In general, gratuitous boxing/unboxing is discouraged because of its performance cost, although the ability to box/unbox value types clearly serves a purpose, and is ingrained into the .Net Framework - the ArrayList type is a perfect example.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
|
Neither. The framework doesn't return 'pi' until you have at least 20 significant digits.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
|
how to display combox in property grid??
simple data type is ok, see this article:
http://www.c-sharpcorner.com/Code/2004/June/PropertyG ridInCSharp.asp
|
|
|
|
|
I have installed window service succesfully (and the system event log also said so); however the service doesnt appear on Sevices at Adminstative tool so i can't start it. Therefore, what I did wrong ?
|
|
|
|
|
If you started the services panel before you installed your service, hitting F5 to refresh may be all that is needed. If shutting down and restarting the Services panel doesn't display your service, then your service must not have been actually installed. Check every relevant log that you can find to see what might have happened.
(Since you're in a C# forum, I assume you wrote the service yourself and used InstallUtil to install ther service. If that is the case, then check your InstallLog files in the directory with your service exe.)
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Have you tried VS 2005 Express Beta 2. Is there something new compared to February CTP? Is at least the documentation more complete?
|
|
|
|
|
Beta 2 has been improved a lot, and it's feature complete. Everything you code in Beta 2 is supposed to be compatible with RTM. It also has a go-live license.
|
|
|
|
|
How to I convert System.Drawing.KnownColor.{item} to a System.Color color. My one attempt at using ColorConverter raised a very nice object exception. Anyone know?
Thx.
There are 10 kinds of people in the world.
Those that read binary...
...and those who don't.
|
|
|
|
|
Since KnownColor is an enum, you can't use the ColorConverter class on it. Just use the Color class' .FromKnownColor() static method to create the color object:
Color someColor = Color.FromKnownColor(KnownColor.whatever);
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Doh! I never noticed that method under Color. It worked, thanks much.
Michael
There are 10 kinds of people in the world.
Those that read binary...
...and those who don't.
|
|
|
|
|
I have a treeview control. I was able to generate the tree nodes for this treeview control by reading the structure of the tree from a database table. At each treenode, I show a check box (CheckBoxes is true). On the Sql Server Side, I have a table which has the following structure:
TreeStruct (NodeID int, NodeDesc varchar(50), NodeState tinyint)
This table is pre populated with information in the order in which the tree will be constructed.
I want to be able to do the following:
(a) whenever the CheckState property changes (i.e., a user Checks/Unchecks a node, I want to commit the change to the database
(b) Let the user make as many changes as possible to the Checkboxes, which will change the CheckState property of the nodes. When the user is done, he/she can press the save button, and all these changes will be written to the database.
I also have an update command in the SqlDataAdapter, which is fetching the data.
So, currently I am looping in a for loop to populate the tree nodes. This process succeeds. But now for users to check/uncheck these check boxes and for me to update the CheckState of these tree nodes, I need to be able to capture these state changes in the data table from where I read the data, and commit these changes to the database.
I am not sure how to bind the data I read from the database to the TreeNode(s) so that I can make the above two things happen.
Help appreciated.
|
|
|
|
|
It looks like your options a) and b) are fighting with each other, but that could just be a misunderstanding on my part. (Committing immediatly would make a save button rather useless.) I'll assume that you want to remember the changes and only send them to the database when they hit "save".
The "Tag" memeber of the TreeNode is where you want to store the data to link the node with the data row. You can do this in a lot of ways. One way would be to simply stick the data row into that tag. If that isn't enough, you can create a class of your own that holds all the data you need. Then, put that class into the Tag of the TreeNode.
One of these methods should get you to where you are going. Good luck!
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
John,
Thanks for your reply.
Just need some more clarification on your suggestion.
I am aware of the "Tag" property of the TreeNode. Once I am done processing the For loop, the tree is populated successfully. At this moment there is no connection between the data table (which was used to populate the tree) and the TreeNodes. I can capture user's action when he/she checks/unchecks a node in the AfterCheck event. But then at that moment, since there is no binding between the data table and the TreeNode data, changes will not be recorded in the data table.
Are you suggesting that I store the node's CheckState value in the node tag, and then some how link the data table and the data in the tag property of all the nodes and then update the source data table manually? It can be done but just wondering if there is a better way so once the nodes and the data table are bound, CheckState changes in these nodes and the data table will happen automatically and the two will be synchronized all the times. If I implement this manually in a round about way I am afraid I will miss some critical steps and mess up something.
Just like DataGrid can be bound to a data table. Is there a similar thing such as binding TreeView control to a data table. MSDN has an example "Extending the TreeView Control" which uses data source but does not go along the path I am trying to go.
Also, the two options I am implementing are mutually exclusive.
John, again, thanks for your help.
|
|
|
|