This is a migrated thread and some comments may be shown as answers.

Filter

1 Answer 47 Views
TextBoxControl
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 1
Ian asked on 24 Feb 2020, 05:42 PM

I am hoping to have a city, state, and name on a page as text box controls. How would I got about setting the datasource to only the results of the other textbox controls if there is a value entered? 

 

So if i have 5 people   with the following info

City      State      Name

Mil         WI         Tools

Mil          IL          Tools

Chi        WI         LLC

Chi         IL          ORG

La          CA        LLC

 

I want to be able to type into the city box 

MIL and then if i go  to the State or Name on it should only have the values of the top two rows

1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 27 Feb 2020, 06:03 AM

Hello Ian,

If I understand you correctly, you would like to implement cascading (dependant) textboxes similar to the cascading combo box approach shown here. When you select an item in the first text box the values that are shown in the second and third text boxes should relatively match to the selected item by some criteria. According to the provided example with the city, state and name it is not clear enough what is the relation between the values.

However, I prepared a sample project with some dummy data to demonstrate how you can restrict the values shown in the second text box based on the selection from the first text box. Please refer to the following code snippet:

public RadForm1()
{
    InitializeComponent();

    this.radTextBoxControl1.AutoCompleteMode = AutoCompleteMode.Suggest;
    RadListDataItemCollection autoCompleteItems = this.radTextBoxControl1.AutoCompleteItems;

    autoCompleteItems.Add(new RadListDataItem("AAA"));
    autoCompleteItems.Add(new RadListDataItem("BBB"));
    autoCompleteItems.Add(new RadListDataItem("CCC"));

    this.radTextBoxControl2.GotFocus += this.RadTextBoxControl2_GotFocus;
}

private void RadTextBoxControl2_GotFocus(object sender, EventArgs e)
{
    if (this.radTextBoxControl1.SelectedText == "AAA")
    {

        this.radTextBoxControl2.AutoCompleteMode = AutoCompleteMode.Suggest;

        RadListDataItemCollection autoCompleteItems = this.radTextBoxControl2.AutoCompleteItems;
        autoCompleteItems.Clear();

        autoCompleteItems.Add(new RadListDataItem("AAA1"));
        autoCompleteItems.Add(new RadListDataItem("AAA2"));
        autoCompleteItems.Add(new RadListDataItem("AAA2"));

    }
    else if (this.radTextBoxControl1.SelectedText == "BBB")
    {
        this.radTextBoxControl2.AutoCompleteMode = AutoCompleteMode.Suggest;

        RadListDataItemCollection autoCompleteItems = this.radTextBoxControl2.AutoCompleteItems;
        autoCompleteItems.Clear();

        autoCompleteItems.Add(new RadListDataItem("BBB1"));
        autoCompleteItems.Add(new RadListDataItem("BBB2"));
        autoCompleteItems.Add(new RadListDataItem("BBB3"));
    }
}

If this does not help, I will kindly ask you to provide more information about what you are trying to achieve.

I am looking forward to your reply.

Regards,
Nadya
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
TextBoxControl
Asked by
Ian
Top achievements
Rank 1
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or