Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-07-17
3
Medium Priority
?
210 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 1500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

688 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