In my application I have a tree view with different node and adjacent to it chart control is there. If I select any of the tree view node corresponding data will plot on chart control. On top of these controls grid is there, this will show the details of the selected node in tree view. All these controls are added in a panel (Called main panel). I have one more panel (For editing purpose called edit panel) behind this main panel. In this panel I am showing the same tree view and one more grid. Here we can edit the details of selected node.
I am handling tree view selections almost like windows explorer. If we loose focus of tree view, I am just graying tree view node. I am just toggling main panel and edit panel if required to edit data of any node.
I used C# 2.0
In this I faced lot of problems.
1. Tree view flicker: When ever I select other node, tree view will flicker. Microsoft can’t able to provide direct solution for this. They suggested work around for this. The work around is use background thread.
a. The funniest thing here is in frame work 2.0 background worker thread has a bug. If you click continuously, frame work will though thread busy exception. Again Microsoft suggested to use Frame work 2.0 service pack1 (SP1).
b. My soft ware requirement is only frame work 2.0. Rests of the other applications are using only 2.0. (Because of back word compatibility issue and already sold software’s and also for some other reasons my bosses insisted not to use SP1.) , Again this came to staring position.
c. Then I use some work around trick like. If(Thread.IsBusy), with this tree view flickering problem is somehow solved.
2. Handling Focus in tree view: User need to select any of node to plot data for that particular node. After selecting any node, the selected node data (Configuration) will be populated to a grid and plot will plot corresponding data.
a. If I want to edit any of the node configuration data, I have to go to edit panel, which I am toggling panel using tool bar button. If I go to edit panel, I am showing same tree view in that panel also (This tree view I am handling as user control). If I loose focus from tree view I am graying the color of selected node like windows explorer.
b. In this panel I selected some other node to edit the configuration of that node. Since I am using the same control, if I change the selection of tree view in edit panel, this will reflect in main panel also. Here I am maintaing some interlocks not lo load the data in plot curve and grid if I am working in edit panel. But I can’t control that for tree view, because I have only one tree view. Here I edited some nodes I traversed to Main panel.
c. While coming from main panel to edit panel , I am holding selected node name in main panel, With that name I am again setting the focus of tree view.
d. You may ask, why I am handling focus using node name instead of node number or node index. Because in edit panel we have an option to move up and move down node positions. If I move node, then node index will change.
e. In Main panel( Plot panel) always grid focus or grid selected item back color should be like highlight, To make that my co project member set the focus to this plot grid and that too he set focus to the grid in timer. At that time I was doing some other work and I lost track of that focus problems. After few days I realized that tree view focus is not there. Also I can’t able to edit the configuration of selected node from edit panel. Because edit panel grid can’t able to hold focus.
f. After few hard hours and I realized that he set focus to main panel grid in timer, because of that tree view and edit grid are not holding focuses, I changed that coding to back ground color change properties.
3. Tree view focus problems with panel visibility: While coming to main panel (plot panel) from edit panel, My application loading like patches, grid is updating first, then tree view and then chart. To minimize those patch refreshes, I hide main panel first after getting data to grid tree view and chart, I shown panel. With this also again I lost tree view focus.
