[Mono-winforms-list] container.Controls.Add changes DataRowVersion to proposed

Andrus kobruleht2 at hot.ee
Sat Feb 10 18:09:48 EST 2007


I found that the following code prints in MONO 1.2.3 preview

No proposed version

MONO creates Proposed version

In .net 2 this code prints only

No proposed version

Any idea why  container.Controls.Add(elem.control); changes row version ?
There is also code in Layout() event maybe this can affect.

 Full procedure is:

public LayoutUserControl(Control container, int layoutNumber,

DataTable table, string formSource, char tableType) {

using (IDataReader dr =

DataAccessBase.ExecDesktopReader(formSource, tableType,

layoutNumber, "veerunimi,controlsrc,doublewidt"))

while (dr.Read()) {

formControl elem = new formControl();

elem.label = new Label();

elem.doublewidth = dr.GetBoolean(2);

elem.label.AutoSize = true;

elem.label.TabStop = false;

container.Controls.Add(elem.label);

Control tb;

string controlsrc = dr.GetString(1).Trim();



tb = new TextBox();

tb.DataBindings.Add("Text", table, controlsrc);



elem.label.Text = dr.GetString(0).Trim();

if (elem.label.Width > ilCaptLen)

ilCaptLen = elem.label.Width;

elem.control = tb;

if (!table.Rows[0].HasVersion(DataRowVersion.Proposed))

System.Windows.Forms.MessageBox.Show(

"No proposed version");

container.Controls.Add(elem.control);

if (table.Rows[0].HasVersion(DataRowVersion.Proposed))

System.Windows.Forms.MessageBox.Show("Proposed version created");

flds.Add(elem);

}

}



I'm unable to create repro code for bugzilla.   I tried the following code
to reproduce the issue but this works OK in MONO (prints Propose test passed
OK)

using System.Windows.Forms;

using System.Data;

static class Program {

static void Main() {

Application.Run(new Frm());

}

}

class Frm : Form {

TabControl tabControl1;

TabPage tabPage2;

TabPage tabPage1;

public Frm() {

DataTable t = new DataTable();

t.Columns.Add("t", typeof(System.String));

t.Rows.Add();

t.Rows[0][0] = "";

tabControl1 = new TabControl();

tabPage1 = new TabPage();

tabPage2 = new TabPage();

tabControl1.Controls.Add(tabPage1);

tabControl1.Controls.Add(tabPage2);

Controls.Add(tabControl1);

Control tb = new TextBox();

tb.DataBindings.Add("Text", t, "t");

tabPage1.Controls.Add(tb);

if (t.Rows[0].HasVersion(DataRowVersion.Proposed))

MessageBox.Show("Unexpected proposed change in MONO");

else

MessageBox.Show("Propose test passed OK");

}

}



More information about the Mono-winforms-list mailing list