|
|
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.
|
|
|
|
|
You should set the Tag property while you are creating the nodes, not in a process after the nodes are created. The tag property should have, at minimum, some way for you to find the database row that needs to be updated.
One simple way of doing this is to:
* Retrieve your data.
* Construct the tree nodes, setting the Tag to that row's ID.
* When the user clicks a node, call the database, setting the appropriate value for the row which is identified by the Tag.
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.
|
|
|
|
|
I am using a three state check box. When a user clicks on a node, I recursively set the CheckState property of the children nodes and parent nodes appropriately. My second option (pressing the save button and committing changes to the DB once) is more suited here as that will take only one round trip call to the database.
John, could you demonstrate by some example how one would update the local data table and the CheckState value in the nodes?
In order in order to successfully record all the changes in the nodes to the data table, I'll loop through all the nodes and copy the CheckState value to the data table. Basically, I have to traverse the entire tree, starting with the root. Is that how you are envisioning?
BTW, I am setting the tag property as I am constructing the nodes, as you suggested.
Help appreciated.
Thanks again
|
|
|
|
|
The save button sounds workable.
That's good that you're already storing the information about which database row corresponds to the TreeNode. Without it, you would have a very hard time doing this.
An example? That's a very tall order, since I don't know anything about the code you are using (data access, type of database, etc.). So, some pseudo-C# code is probably the best I can do.
<br />
private void SaveButton_Clicked(object sender, EventArgs e)<br />
{<br />
SomethingOrOther data = new SomethingOrOther();<br />
<br />
foreach (TreeNode node in yourTree.Nodes)<br />
{<br />
YourClassInfo info = node as YourClassInfo;<br />
data.QueueUpdate(info.Row, node.Checked);<br />
}<br />
<br />
data.Save();<br />
}<br />
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.
|
|
|
|
|
I basically just want to send a 2 part message. Part 1: text, Part 2: Html.
Any ideas on how I'm going to get this into my .NET application?
|
|
|
|
|
http://www.quiksoftcorp.com/freesmtp/
in case anyone wants to know
|
|
|
|
|
Hi All,
I have created a database in SQL and setup relationships the works. What happens is, when you enter info from a website, numeric values gets written to SQL.
What I need is to display the data behind the values in a datagrid. I have created a stored procedure to inner join the needed data but how do I execute the stored procedure to display the data in a datagrid?
Thanks!
Illegal Operation
WannaBe and GonnaBe Systems Developer
|
|
|
|