why the same code have different result between pc and ppc
Sample Code (run as windows form ):
create a form , add treeView control and add code as show following in form_load method.
bool isSelected = false;
treeView1.CheckBoxes = true;
TreeNode tn;
for(int i=0;i<40;i++)
{
if(i%2==0) isSelected = true;
else isSelected = false;
tn = new TreeNode("Demo"+i.ToString());
tn.Checked = isSelected;
treeView1.Nodes.Add(tn);
}
Now you can clearly look the result of running.
frist on pc the result is wannted.but on ppc no any checkbox was checked
why

why the same code have diffren result between PC and PPC?
LogicMagic
thanks ting_msf
Throught i have the result right, but i hope to know:
why
tn.checked =isSelected
after
treeView1.Nodes.Add(tn)
in my opinion tn that must be set up the properties of tn then add to treeView.
RSDuren
tn.Checked = isSelected; this sentence no effect in ppc.
the result of running is no any checkbox was checked in ppc.
but it's right in pc.
SHIYAS
Greg Eisenberg
This is a bug in .NETCF 1.0 that has been fixed in v2.
Setting properties on a TreeNode should not depend on whether the node has been added to a TreeView.
Jon Jacobs
I am unable to reproduce what you are seeing. With the code copied from your post, I see on both PPC (2003 emulator) and desktop every other node in the treeview checked.
I am using Visual Studio 2005 and .NETCF 2.0.
Using .NET Compact Framework 1.0, I do see the behaviour you describe, but if I change your code to the following (as previously suggested), every other node in the treeview is checked.
bool isSelected = false;treeView1.CheckBoxes = true;
TreeNode tn;
for (int i = 0; i < 40; i++)
{
if (i % 2 == 0) isSelected = true;
else isSelected = false;
tn = new TreeNode("Demo" + i.ToString());
treeView1.Nodes.Add(tn); // reversed form the original
tn.Checked = isSelected; // these two lines are switched/
}