Solved

How will I get the saved history of textbox (text which is previously entered) in vb.net ?

Posted on 2013-05-29
4
370 Views
Last Modified: 2013-07-07
How will I get the saved history of textbox (text which is previously entered)  in vb.net ?

Thanks in advance
0
Comment
Question by:hc_gupta
  • 2
4 Comments
 
LVL 42

Expert Comment

by:sedgwick
Comment Utility
u can use any available .Net data structure to store previous textbox values, like List, Queue, etc.
i'd create class like this:
    public class TextHistory
    {
        private List<string> history = new List<string>();
        public void Add(string text)
        {
            history.Add(text);
        }
        public IList<string> History
        {
            get { return history.AsReadOnly(); }
        }
    }

Open in new window

0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
Comment Utility
to use it simply add a member in your winform class.
public class MyForm : Form{
private TextHistory myHistory = new TextHistory();

}

Open in new window

each time user enter text call the Add function which the textbox.Text.
whenever u need to get all previous history, simply call the property History.
if u want a more generic history object which stores different types not only string, then u can use a generic form of the history class:
    public class GenericHistory<T>
    {
        private List<T> history = new List<T>();
        public void Add(T text)
        {
            history.Add(text);
        }
        public IList<T> History
        {
            get { return history.AsReadOnly(); }
        }
    }

Open in new window


now, to declare the type of the history class use this way, this example for integer:
public class MyForm : Form{
private GenericHistory<int> myHistory = new GenericHistory<int>();

}

Open in new window

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now