|
treeView2.Nodes.Clear();
foreach(TreeNode node in treeView1.Nodes){
treeView2.Nodes.Add(node);
}
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Thanks but I got:
Cannot add or insert the item 'Dogs & Cats' in more than one place. You must first remove it from its current location or clone it.
Parameter name: node
|
|
|
|
|
AngryC wrote: You must first remove it from its current location or clone it.
I'm gonna take a stab in the dark and suggest TreeNode.Clone() .
foreach (TreeNode tn in treeView1.Nodes) {
treeView2.Nodes.Add(tn.Clone() as TreeNode);
}
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
Hi, Does anybody know how to make a TextBox Array in a C#.NET Web Application?
And for CheckBoxes?
Oren,
|
|
|
|
|
TextBox[] tb = new TextBox[3];
CheckBox[] cb = new CheckBox[3];
:josh:
My WPF Blog[^]
|
|
|
|
|
Ok... I would have not think it was so simple, .
Thanks!
Oren,
|
|
|
|
|
hi i had get the color through color dialog box and saved them in database nd then i want to set on the form?
then i want to set the color of dalog reading from the datbase but it gives error that cannot change readonly property.
System.drawing.color clr=new color();
clr.A=a;//read from db; //gives error that cannot change readonly property
.R=b;
.B=v//et
now i want to set the form color to this.
this.color=clr;
how to assign values to color variables?
Tasleem Arif
|
|
|
|
|
Color is a struct and therefore mutable, supply values to it's static FromArgb method instead of trying to set properties after initialization.
Color c = Color.FromArgb(r, g, b);
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
as it is more suited to saving in a database.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
BoneSoft wrote: Color is a struct and therefore mutable,
You're correct in this case (if you prepend "im" to the word "mutable"), but structs in general are not necessarily immutable. Immutability of structs is a best practice, not a rule.
:josh:
My WPF Blog[^]
|
|
|
|
|
Woops! My intellisence ain't working today. Thanks for catching that.
And my understanding was that all structs are immutable, trying to change them just creates and swaps a new one behind the scenes, like strings or any other stacked value. So they seem to be mutable, though technically they are not. Maybe I have it wrong...
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
BoneSoft wrote: And my understanding was that all structs are immutable, trying to change them just creates and swaps a new one behind the scenes, like strings or any other stacked value
Structs (aka 'value types') are copied by reference, but that doesn't imply immutability.
This code creates a Point struct and modifies it (not a copy of it):
Point pt = new Point(1,1);
pt.X = 2;
:josh:
My WPF Blog[^]
|
|
|
|
|
Can you group together CheckBoxes so only one in a group is checked at one time and if so How?
|
|
|
|
|
Winforms or ASP.NET?
If Winforms:
Use RadioButtons instead of CheckBoxs. Put them in a GroupBox or Panel and they'll automatically be mutually exclusive.
:josh:
My WPF Blog[^]
|
|
|
|
|
Winforms, and i can't use Radion buttons because i am looking for the sticky button look that a check box has.
|
|
|
|
|
Your users will be confused by mutually exclusive checkboxes. It's atypical and, hence, weird. When it comes to UIs, stick to conventions unless you have a very good reason not to.
:josh:
My WPF Blog[^]
|
|
|
|
|
What the hell is "sticky button look"? Can I use that next time I'm at the pool?
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
You deserve to be thrown off a cliff for doing so. Check box are designed so you can select multiple. Options are designed to choose. Switching the two will only confuse people.
That said, create a collection of all of the check boxes you want to enforce one check only. Add a listener to all the check boxes for CheckedChanged to the same method. In the method loop through all of the check boxes in the collection if the sender object is a check box that is true and set all other check boxes to unchecked.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
private void checkBox_CheckedChanged(object sender, EventArgs e) {
if(sender is CheckBox){
if(((CheckBox)sender).Checked){
foreach(CheckBox ck in list){
if(ck != sender){
ck.Checked = false;
}
}
}
}
}
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
LMAO my bad, I'm sorry thanks for the help though sounds like a good solution
|
|
|
|
|
I have a centralcserver that receives SNMP traps for a number of other devices within a very large network (6000+ trap generating devices).
I need to find a mechanism that will allow me to decode the raw SNMP data into something that is human readable.
Does anybody know of any C# based libraries that are capable of doing this?
|
|
|
|
|
|
Read the textbook again or audit the class
|
|
|
|
|
Try this one:
StreamReader s = new StreamReader(@"f:\mytext.txt");
ArrayList a = new ArrayList();
while (s.Peek() >= 0)
{
string alltext = "";
string text = "";
while ((text = s.ReadLine()) != "" && text != null)
{
alltext += ("|" + text);
}
a.Add(alltext);
}
s.Close();
foreach (string text in a)
{
string[] splitString = text.Split('|');
string tempstring = "";
for (int i = 3; i < splitString.Length; i++)
{
tempstring += splitString[i];
}
ListViewItem lvi = new ListViewItem(new string[] { splitString[1], splitString[2].Substring(0, 12), splitString[2].Substring(17, 12), tempstring });
this.listView1.Items.Add(lvi);
}
|
|
|
|
|
Wow, nothing like doin' his classwork for him. Now he'll definately fail the class!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|