Hello,
a strange, but probably simple, problem drives me nuts:
I have simple databinding of textbox to bindingsource(bound to
dataset), created in form constructor:

public Form3(string xyz)
{
InitializeComponent();

Program.bs.AddNew();
textBox1.DataBindings.Add("Text", Program.bs, "cmType");

textBox1.Text = xyz; // <-nothing happens
}

all I want is to add a new row to dataset, and set a value of column
"cmType" programatically in form constructor. Problem is that result of
program above is blank textBox1, and no data in "cmType".
If i fill textBox1 in onFormShow event, everything goes ok.
Anyone can help?
thx

Re: databinding in form conctructor by Bryan

Bryan
Fri Oct 27 17:02:22 CDT 2006

You should move the code to the OnLoad event or any event afterwards to
allow the form and its controls to fully initialize.

Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com




"tomse" <tomse@go2.pl> wrote in message
news:1161370407.326085.271380@m7g2000cwm.googlegroups.com:

> Hello,
> a strange, but probably simple, problem drives me nuts:
> I have simple databinding of textbox to bindingsource(bound to
> dataset), created in form constructor:
>
> public Form3(string xyz)
> {
> InitializeComponent();
>
> Program.bs.AddNew();
> textBox1.DataBindings.Add("Text", Program.bs, "cmType");
>
> textBox1.Text = xyz; // <-nothing happens
> }
>
> all I want is to add a new row to dataset, and set a value of column
> "cmType" programatically in form constructor. Problem is that result of
> program above is blank textBox1, and no data in "cmType".
> If i fill textBox1 in onFormShow event, everything goes ok.
> Anyone can help?
> thx