question

BonginkosiNkambule-6299 avatar image
0 Votes"
BonginkosiNkambule-6299 asked JackJJun-MSFT edited

Form fields auto population

Good day,

I hope you are all doing well. Please kindly help me, I need a way to auto fill my form will all the relevant data to the ID selected from the first text field. Once I select the ID in the first textbox then the other fields or textboxes shows the data corresponding to that ID.

not-supported
· 11
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Please provide us more information about what you're doing along with any relevant code. We don't understand what "form" you mean (Winforms? Form in a document?, form on a webpage?) We also don't understand what "select the ID in the first textbox" means. It sounds like you're trying to build a winforms form that allows the user to enter an ID and then you show the corresponding data in the remainder of the UI. But at this point we're just guessing.

Please use the Code Sample button to post the relevant code you currently have.

0 Votes 0 ·

Good day,

Apologies for that confusion caused.

"It sounds like you're trying to build a winforms form that allows the user to enter an ID and then you show the corresponding data in the remainder of the UI. But at this point we're just guessing." - Yes, this is exactly what I am talking about.

0 Votes 0 ·
cooldadtx avatar image cooldadtx BonginkosiNkambule-6299 ·

Do you have any existing code you can share? There are several different ways to solve your problem but it depends on how you have built your app.

The simplest approach would be to query the data when the user clicks the "Submit" button. I'm assuming here that the user enters an ID and then clicks a button to retrieve the data. So your button handler would look the data up and then set the remaining controls on the form based upon the data returned.

private void button1_Clicked ( object sender, EventArgs e )
{
   //Get entered ID (ignoring error handling here...)
   var id = GetId();

   var data = GetDataFromYourDatabase(id);
   if (data != null)   //If we go the data
   {
       //Set UI
       _txtName.Text = data.Name;
       _txtDescription.Text = data.Description;
   };
}


If you want something more elaborate then you'll need to use data binding. For this you might look into using BindingSource. But if you don't need that advanced functionality then I'd keep it simple.

0 Votes 0 ·
Show more comments

Hi BonginkosiNkambule-6299,

This openspecs tags handle requests related to Open Specifications documentation issues.
The Open Specifications can be found at: http://msdn.microsoft.com/en-us/library/cc203350.aspx.
Your question does not appear to be related to the Open Specifications documentation set, so I will remove the openspecs-office-fileformats tag. If you feel this is in error, please reference the document you would like assistance with, and add the tag back to your post.

Thank you,
Kristian S
Support Escalation Engineer
Windows Protocols


0 Votes 0 ·

0 Answers