There is no method that I know of that will do what you want. But there are ways in which to accomplish what I think you want. Here's one.
Use a ComboBox, instead of a TextBox. I assume that your button signals that text is available in your TextBox. This same concept applies to the ComboBox. Declare a list that will contain all of the input entered earlier by your user. It will initially be empty.
List < string > earlier_entries = new List < string > ( );
If you want to keep the input from earlier executions, save and restore the list to/from a user-accessible file.
Let's name the ComboBox user_entry_CB and the Button user_entry_BUT.
The following code is the event handler for the user_entry_BUT click event.
private void user_entry_BUT_Click ( object sender,
EventArgs e )
{
if ( String.IsNullOrEmpty ( user_entry_CB.Text ) )
{
MessageBox.Show ( "You must supply an entry",
"Missing Entry" );
}
else
{
string text = user_entry_CB.Text;
if ( !earlier_entries.Contains ( text ) )
{
earlier_entries.Add ( text );
}
user_entry_CB.Text = String.Empty;
user_entry_CB.DataSource = null;
user_entry_CB.DataSource = earlier_entries;
user_entry_CB.Focus ( );
}
}
The only trick is to maintains the earlier user entries in the list and setting the DataSource of the ComboBox to the list. Remember to set the ComboBox's DataSource to null before reassigning the list to it.
Hope that helps.