Solved

How do I implement the backward and forward (the 2 arrows buttons) in a window's form?

Posted on 2006-07-17
3
207 Views
Last Modified: 2011-09-20
Are there contols or sample code avaiable to implement this?  I'm coding a form with treeview on left and listview on right of a container control.  It's like the Active Directory's computer, user and groups console.  The backward and forward button would change the display of the Treeview and the Listview to previous or forwarded user's selected node.

Thanks.
0
Comment
Question by:lapucca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 14

Expert Comment

by:jjardine
ID: 17127854
I have not created this functionality but here is an idea of how you could do it.  

Create an array or arraylist that holds the list of tree nodes that the user clicks on.
Store the index that the user is currently on.

As the user selects the nodes,   Add them to the array and increment the index.  

When the user clicks the back button then subtract 1 from the index and select that node.  

When the user clicks the forward button then add 1 to the index and select that node.  

Hope that helps with an idea for how to solve this.
0
 

Accepted Solution

by:
martin75a earned 500 total points
ID: 17128163
Some code how to accomplish it:

using System.Collections;

...

private ArrayList backList = new ArrayList();
private ArrayList forwardList = new ArrayList();

...

(add two buttons, backButton and forwardButton, and in constructor:)
backButton.Enabled = false;
forwardButton.Enabled = false;

...

private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
{
forwardList.Clear();
forwardButton.Enabled = false;
backList.Add(e.Node);
backButton.Enabled = true;
// code to update the items in the listview
// ...
}

private void backButton_Click(object sender, EventArgs e)
{
TreeNode node = (TreeNode)backList[backList.Count - 1];
backList.Remove(node);
if (backList.Count == 0)
{
backButton.Enabled = false;
}
forwardList.Add(node);
forwardButton.Enabled = true;
treeView.SelectedNode = node;
treeView_AfterSelect(treeView, new TreeViewEventArgs(node));
}

private void forwardButton_Click(object sender, EventArgs e)
{
TreeNode node = (TreeNode)forwardList[0];
forwardList.Remove(node);
if (forwardList.Count == 0)
{
forwardList.Enabled = false;
}
backList.Add(node);
backButton.Enabled = true;
treeView_AfterSelect(treeView, new TreeViewEventArgs(node));
}


This is to get you started, you may want to add more checks to prevent errors.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question