|
Just do exactly what you just said
// Create the new node.
TreeNode newNode = new TreeNode();
// Copy any appropriate properties.
newNode.Text = oldNode.Text;
newNode.OtherStuff = oldNode.OtherStuff;
// Apply your modification
newNode.Text += "This text has been changed by me";
// Add the new node to the treeview.
treeView.Nodes.Add(newNode);
Simon
|
|
|
|
|
|
When saving the TreeNode as a new object you should use the Clone() member.
TreeNode workNode=TreeView.Nodes[0].Clone();
When setting it back to the TreeView you should remove the old node and add the new.
TreeView.Nodes.RemoveAt(0);<br />
TreeView.Nodes.AddAt(0,workNode);
/Ruben
RJJournal
|
|
|
|
|
I've put a SQL Data Access class together which returns a DataSet.
I wanted it to be generic, therefore wrote a method to return a dataset. I am using typed datasets within my application however and the cast throws an error;
MyDefinedSchemaDataSet myDS = (MyDefinedSchemaDataSet)myDataAccessClass.DoSelectStoredProcedure("procStoredProcedureName");
If i use DataAdapter.Fill on a MyDefinedSchemaDataSet.MyDefinedDataTable everything works and there are no errors, however that would throw the idea of a generic method out of the window...
what to do!?
|
|
|
|
|
Try this
DataSet utDataset = myDataAccessClass.DoSelectStoredProcedure("procStoredProcedureName");
MyDefinedSchemaDataSet myDS = new MyDefinedSchemaDataSet();
myDS.Load(utDataset.Tables[0].CreateDataReader(), LoadOption.OverwriteChanges, myDS.myTableName);
Just change the values where appropriate.
Broken Bokken
You can't carry out a ninja-style assasination dressed as an astronaut. It's the luminous fabric; too visible. - Tripod
http://www.brokenbokken.com
|
|
|
|
|
works perfectly! thanks thats what i've been looking for!!!!
think i'll pass parameters in as an arraylist... although not certain yet...
|
|
|
|
|
you should look into using the params keyword instead of an arraylist.
public void MyMethod(params object[] parameters)
{
}
When you call it you can pass them in without having to create a list. You can add as many parameters as you want and is great when you need to pass a list as a parameter to a method.
Broken Bokken
You can't carry out a ninja-style assasination dressed as an astronaut. It's the luminous fabric; too visible. - Tripod
http://www.brokenbokken.com
|
|
|
|
|
Hi,
How to convert the "CCITT u-Law" audio format file to PCM audio format?
Please help me.
Thanks,
Gopal.S
|
|
|
|
|
|
You could also start a process and call SOX[^] with the correct parameters for your input and output files.
|
|
|
|
|
Dear all;
i recently start programming with C#, and am developing a database project using ms access 2003 and C#... i did the connection using ADO.NET libraries ... locally everything is ok... but when i tried to move the database to another computer within the workgroup and run the application an error concerning the connections appears..
am wondering if access is a good choice to use or if its support this kind of network connection??????
any help....
regards
|
|
|
|
|
Can you use SQL Server instead of MS Access? If yes, I would suggest you to use SQL Server.
However to connect to MS Access on a shared folder, you can create DSN and use ODBC model in your .net application
Regards,
Dave
Dave Traister
Software Engineer
ComponentOne LLC
www.ComponentOne.com
|
|
|
|
|
Hello everyone,
I have verified that the result of 100/0 will not occur any exception, and it will be infinite.
Does it mean there is no exceptions like divide by zero in C#?
thanks in advance,
George
|
|
|
|
|
Eh? How did you do this. If I run the following code, I get a divide by zero exception:
int value1 = 100;
int value2 = 0;
try
{
int output = value1 / value2;
}
catch (DivideByZeroException dbz)
{
Console.WriteLine("I'm here");
} Cunningly, the code hits the DivideByZeroException .
|
|
|
|
|
Here is my code, no exception. Any comments, Pete?
static void Main(string[] args)
{
try
{
float a = 100;
float b = 0;
float c = a / b;
}
catch (Exception ex)
{
Console.WriteLine("{0}", ex.ToString());
}
return;
}
}
regards,
George
|
|
|
|
|
Wow, very interesting. I never knew that. Yes, I can reproduce that effect with your code.
There are 2 constants:
float.PositiveInfinity
float.NegativeInfinity
and a method:
float.IsInfinity()
I suspect this is related to the imprecision[^] of floating point numbers stored in binary.
Anyone know the full reason for this?
Simon
|
|
|
|
|
Thanks Simon,
I understand how float number is stored in binary format, but why do you think the binary format impacts the result -- other than throw exception, infinity value will be got -- compared with integer type?
regards,
George
|
|
|
|
|
George_George wrote: Any comments, Pete?
Yup. I divided 100 by 0, and you didn't. You divided a float with a value of 100 by a float with a value of 0, which aren't actually 100 and 0. It's a subtle one, but there it is. The int class doesn't have the concept of NaN or Infinity so will yield a divide by zero exception. The converse applies to the float class.
|
|
|
|
|
Great, thanks Pete!
regards,
George
|
|
|
|
|
For int, there is exception, but for float, there is no exception. Can you reproduce?
regards,
George
|
|
|
|
|
A floating point value can be infinite, so there is no exception.
An integer can not be infinite, so an integer division will cause an exception when you divide by zero.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
What reason is there to allow a floating point number to be infinite?
there is a float.MaxValue constant that I thought was the maximum value of a single prevision float. If a float has a pre defined maximum value, why allow it to also store infinity, without all of the number in between?
[EDIT]
Interestingly, if you cast infinity to an integer, you get -2147483648, which is int.MinValue;
static void Main(string[] args)
{
try
{
float a = 100;
float b = 0;
float c = a / b;
int d = (int)c;
}
catch (Exception ex)
{
Console.WriteLine("{0}", ex.ToString());
}
return;
}
[/EDIT]
Simon
modified on Thursday, April 24, 2008 6:34 AM
|
|
|
|
|
Answered my own question.
It seems this is the IEEE standard way of handling floating point numbers:
Divide by zero exception[^]
from msdn: Dividing a floating-point value by zero will result in either positive infinity, negative infinity, or Not-a-Number (NaN) according to the rules of IEEE 754 arithmetic. Floating-point operations never throw an exception.
Single structure[^]
from msdn: If the magnitude of the result of a floating-point operation is too large for the destination format, the result of the operation is PositiveInfinity or NegativeInfinity, as appropriate for the sign of the result.
Simon
|
|
|
|
|
Thanks Simon,
1.
From the links you referred, here is the information I found related to this question. So, it means only int and decimal type has DivideByZeroException? Float/Double escape this situation?
--------------------
The exception that is thrown when there is an attempt to divide an integral or decimal value by zero.
--------------------
2.
What else information do you find relates to the question I asked in the two links you referred?
regards,
George
|
|
|
|
|
But still, the result of division by zero is undefined, not infinite.
|
|
|
|