Click here to Skip to main content
14,356,475 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am able to retrieve data from my database via stored procedure and then get that data to display in a list box easy.
NOTE i am also using dapper.

Now instead of displaying that data in a list box, i want to bind/display that data in a text-box or a string variable, as the data doesn't need a list box its only one single string.

What I have tried:

List<Locations_Info> loadelocations = new List<Locations_Info>();


      GetLocationImage getlimage=new GetLocationImage();


     Selection = (FoodLocationList.GetItemText(FoodLocationList.SelectedItem));


          loadelocations = getlimage.Getimagepath(Selection);


          textBox1.Text = loadelocations.ToString();
Posted
Updated 26-Aug-19 10:32am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You can use Data Binding, see CodeProject article: A Detailed Data Binding Tutorial[^]

And here is an article about implementing your own binding class: Understanding Simple Data Binding[^]
I think this can be adapted to support other objects, good luck !
(be sure to also read the comment about INotifyPropertyChanged)
   
v4
Comments
Member 12321939 26-Aug-19 17:35pm
   
Thanks, i figured it out by messing with some code.
textBox1.DataBindings.Clear();
textBox1.DataBindings.Add("Text", SAMPLE, "FullImagepath");
Member 12321939 26-Aug-19 17:36pm
   
now is there a way to use a string variable instead of the textbox :-)??????????

in this case i would have to hide the text-box and i would rather not have a hidden text-box just for this purpose.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100