The Dictionary class does not implement IList. which I believe, is necessary for the Binding behaviour. Therefore, you could create a BindingSource object and add your dictionary as a Datasource to it. The BindingSource class is cool in the way that it exposes any object added to it as a List. This could then be supplied as a datasource object to the Binding constructor.
I'm mostly guessing here, so you should try it with a pinch of salt. On Aug 6, 7:15 pm, Jens Botzenhardt <[email protected]> wrote: > Hej > > I have a dictionary<string, string>. Based on the dictionary the > program draws a form consisting of labels and textboxes. Every key- > value-pair resembles to a label and a textbox. The text of the labels > equals the key of the dictionary, the value is respectively the text > of the textbox. > > I am trying to bind the text of the textbox to the value of the > textbox. > I tried the following approach, but my code does not compile. > > textBox.DataBindings.Add("text", dict, "Value"); > > where dict is my dictionary. > > Was is my error in reasoning? Is it not possible to bind a value to a > textbox? > > I know, it would be possible using events, but I would prefer to bind > the values. > > Thanks for your help > Jens
