Re: [Mono-winforms-list] TreeView.TreeViewNodeSorter seem to have no effect
Hey! This should be fixed in rev 155655 (svn). Thanks, Carlos. 2010/3/24 Latif Khalifa lati...@radegastclient.org I finally managed to figure out under what circumstances the bug shows. I have a single root node, creatively labeled root. In that case TreeView ignores the sorter and sorts alphabetically. Here is my simple Compare() that is supposed to sort nodes in reverse alphabetical order: public class SorterClass : System.Collections.IComparer { public int Compare(object a, object b) { int res = string.Compare(((TreeNode)a).Text, ((TreeNode)b).Text); res *= -1; return res; } } And here is a short example that creates TreeView: invTree = new TreeView(); invTree.Dock = DockStyle.Fill; invTree.TreeViewNodeSorter = new SorterClass(); Controls.Add(invTree); TreeNode root = new TreeNode(My root); invTree.Nodes.Add(root); for (char c = 'A'; c = 'Z'; c++) { TreeNode n = new TreeNode(); n.Text = c.ToString(); n.Name = c.ToString(); for (int i=0; i20; i++) { TreeNode inside = new TreeNode(i.ToString()); n.Nodes.Add(inside); } root.Nodes.Add(n); } invTree.Sort(); Two observed behaviors differ from .net 1) Bug, Setting TreeViewNodeSorter has no effect if there is only one top level node. (actually it does have an effect of turning on sorting, just that the Compare() is never called and sorting is done by a default system function). 2) Different behavior. On Windows under .NET one does not need to explicitly call Sort(). Nodes are sorted as they are inserted. Latif On Tue, Mar 23, 2010 at 7:03 PM, Carlos Alberto Cortez calberto.cor...@gmail.com wrote: Hey! I tested this on those same versions, and I cannot get the error. Could you cook a small test case? Carlos. 2010/3/23 Latif Khalifa lati...@radegastclient.org Hello, I have had this problem with both 2.4.2.3 and 2.6.3. Identical code works on .net side, in mono's TreeView sorting is always alphabetic and my Compare() never gets called. Latif On Tue, Mar 23, 2010 at 4:00 PM, Carlos Alberto Cortez calberto.cor...@gmail.com wrote: Hey, This should be working. Maybe you hit a bug, but it seems, based on the other information, that you are using an old version. Take a look at that and let us know. Carlos. 2010/3/23 Latif Khalifa lati...@radegastclient.org Hi, I'm trying to cure a few last quirks an an application I'm porting from windows. The problem I'm having is that setting TreeView.TreeViewNodeSorter seem to have no effect. The nodes gets sorted alphabetically and Compare() in my IComparer class never gets called. Any ideas? Also TreeView seem to be missing [+] and [-] images next to the nodes that can be expanded and collapsed. Latif ___ Mono-winforms-list maillist - Mono-winforms-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list ___ Mono-winforms-list maillist - Mono-winforms-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list
Re: [Mono-winforms-list] TreeView.TreeViewNodeSorter seem to have no effect
I finally managed to figure out under what circumstances the bug shows. I have a single root node, creatively labeled root. In that case TreeView ignores the sorter and sorts alphabetically. Here is my simple Compare() that is supposed to sort nodes in reverse alphabetical order: public class SorterClass : System.Collections.IComparer { public int Compare(object a, object b) { int res = string.Compare(((TreeNode)a).Text, ((TreeNode)b).Text); res *= -1; return res; } } And here is a short example that creates TreeView: invTree = new TreeView(); invTree.Dock = DockStyle.Fill; invTree.TreeViewNodeSorter = new SorterClass(); Controls.Add(invTree); TreeNode root = new TreeNode(My root); invTree.Nodes.Add(root); for (char c = 'A'; c = 'Z'; c++) { TreeNode n = new TreeNode(); n.Text = c.ToString(); n.Name = c.ToString(); for (int i=0; i20; i++) { TreeNode inside = new TreeNode(i.ToString()); n.Nodes.Add(inside); } root.Nodes.Add(n); } invTree.Sort(); Two observed behaviors differ from .net 1) Bug, Setting TreeViewNodeSorter has no effect if there is only one top level node. (actually it does have an effect of turning on sorting, just that the Compare() is never called and sorting is done by a default system function). 2) Different behavior. On Windows under .NET one does not need to explicitly call Sort(). Nodes are sorted as they are inserted. Latif On Tue, Mar 23, 2010 at 7:03 PM, Carlos Alberto Cortez calberto.cor...@gmail.com wrote: Hey! I tested this on those same versions, and I cannot get the error. Could you cook a small test case? Carlos. 2010/3/23 Latif Khalifa lati...@radegastclient.org Hello, I have had this problem with both 2.4.2.3 and 2.6.3. Identical code works on .net side, in mono's TreeView sorting is always alphabetic and my Compare() never gets called. Latif On Tue, Mar 23, 2010 at 4:00 PM, Carlos Alberto Cortez calberto.cor...@gmail.com wrote: Hey, This should be working. Maybe you hit a bug, but it seems, based on the other information, that you are using an old version. Take a look at that and let us know. Carlos. 2010/3/23 Latif Khalifa lati...@radegastclient.org Hi, I'm trying to cure a few last quirks an an application I'm porting from windows. The problem I'm having is that setting TreeView.TreeViewNodeSorter seem to have no effect. The nodes gets sorted alphabetically and Compare() in my IComparer class never gets called. Any ideas? Also TreeView seem to be missing [+] and [-] images next to the nodes that can be expanded and collapsed. Latif ___ Mono-winforms-list maillist - mono-winforms-l...@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list ___ Mono-winforms-list maillist - Mono-winforms-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list
Re: [Mono-winforms-list] TreeView.TreeViewNodeSorter seem to have no effect
Hey, This should be working. Maybe you hit a bug, but it seems, based on the other information, that you are using an old version. Take a look at that and let us know. Carlos. 2010/3/23 Latif Khalifa lati...@radegastclient.org Hi, I'm trying to cure a few last quirks an an application I'm porting from windows. The problem I'm having is that setting TreeView.TreeViewNodeSorter seem to have no effect. The nodes gets sorted alphabetically and Compare() in my IComparer class never gets called. Any ideas? Also TreeView seem to be missing [+] and [-] images next to the nodes that can be expanded and collapsed. Latif ___ Mono-winforms-list maillist - Mono-winforms-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list ___ Mono-winforms-list maillist - Mono-winforms-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list
Re: [Mono-winforms-list] TreeView.TreeViewNodeSorter seem to have no effect
Hello, I have had this problem with both 2.4.2.3 and 2.6.3. Identical code works on .net side, in mono's TreeView sorting is always alphabetic and my Compare() never gets called. Latif On Tue, Mar 23, 2010 at 4:00 PM, Carlos Alberto Cortez calberto.cor...@gmail.com wrote: Hey, This should be working. Maybe you hit a bug, but it seems, based on the other information, that you are using an old version. Take a look at that and let us know. Carlos. 2010/3/23 Latif Khalifa lati...@radegastclient.org Hi, I'm trying to cure a few last quirks an an application I'm porting from windows. The problem I'm having is that setting TreeView.TreeViewNodeSorter seem to have no effect. The nodes gets sorted alphabetically and Compare() in my IComparer class never gets called. Any ideas? Also TreeView seem to be missing [+] and [-] images next to the nodes that can be expanded and collapsed. Latif ___ Mono-winforms-list maillist - mono-winforms-l...@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list ___ Mono-winforms-list maillist - Mono-winforms-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list
Re: [Mono-winforms-list] TreeView.TreeViewNodeSorter seem to have no effect
Hey! I tested this on those same versions, and I cannot get the error. Could you cook a small test case? Carlos. 2010/3/23 Latif Khalifa lati...@radegastclient.org Hello, I have had this problem with both 2.4.2.3 and 2.6.3. Identical code works on .net side, in mono's TreeView sorting is always alphabetic and my Compare() never gets called. Latif On Tue, Mar 23, 2010 at 4:00 PM, Carlos Alberto Cortez calberto.cor...@gmail.com wrote: Hey, This should be working. Maybe you hit a bug, but it seems, based on the other information, that you are using an old version. Take a look at that and let us know. Carlos. 2010/3/23 Latif Khalifa lati...@radegastclient.org Hi, I'm trying to cure a few last quirks an an application I'm porting from windows. The problem I'm having is that setting TreeView.TreeViewNodeSorter seem to have no effect. The nodes gets sorted alphabetically and Compare() in my IComparer class never gets called. Any ideas? Also TreeView seem to be missing [+] and [-] images next to the nodes that can be expanded and collapsed. Latif ___ Mono-winforms-list maillist - Mono-winforms-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list ___ Mono-winforms-list maillist - Mono-winforms-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list
Re: [Mono-winforms-list] TreeView.TreeViewNodeSorter seem to have no effect
Just to clarify, I don't get any error messages either, it just doesn't use the custom IComparer class I specify. Are you able to sort nodes in say reverse alphabetical order? If yes, I will try to cook up a small test case. On Tue, Mar 23, 2010 at 7:03 PM, Carlos Alberto Cortez calberto.cor...@gmail.com wrote: Hey! I tested this on those same versions, and I cannot get the error. Could you cook a small test case? Carlos. 2010/3/23 Latif Khalifa lati...@radegastclient.org Hello, I have had this problem with both 2.4.2.3 and 2.6.3. Identical code works on .net side, in mono's TreeView sorting is always alphabetic and my Compare() never gets called. Latif On Tue, Mar 23, 2010 at 4:00 PM, Carlos Alberto Cortez calberto.cor...@gmail.com wrote: Hey, This should be working. Maybe you hit a bug, but it seems, based on the other information, that you are using an old version. Take a look at that and let us know. Carlos. 2010/3/23 Latif Khalifa lati...@radegastclient.org Hi, I'm trying to cure a few last quirks an an application I'm porting from windows. The problem I'm having is that setting TreeView.TreeViewNodeSorter seem to have no effect. The nodes gets sorted alphabetically and Compare() in my IComparer class never gets called. Any ideas? Also TreeView seem to be missing [+] and [-] images next to the nodes that can be expanded and collapsed. Latif ___ Mono-winforms-list maillist - mono-winforms-l...@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list ___ Mono-winforms-list maillist - Mono-winforms-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list
[Mono-winforms-list] TreeView.TreeViewNodeSorter seem to have no effect
Hi, I'm trying to cure a few last quirks an an application I'm porting from windows. The problem I'm having is that setting TreeView.TreeViewNodeSorter seem to have no effect. The nodes gets sorted alphabetically and Compare() in my IComparer class never gets called. Any ideas? Also TreeView seem to be missing [+] and [-] images next to the nodes that can be expanded and collapsed. Latif ___ Mono-winforms-list maillist - Mono-winforms-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list