473,725 Members | 2,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ComboBox DateTimePicker Binding Focus Bug / Mess

I've come across an interesting bug.
I have workarounds but i'd like to know the root of the problem. I've
stripped it down into a short file and hope someone might have an idea about
what's going on.

It's a simple program that loads a control onto a form and binds "Foo"
against a combobox ("SelectedItem" ) for it's "Bar" property and a
datetimepicker ("Value") for it's "DateTime" property. The
DateTimePicker. Visible value is set to false.
Once it's loaded up, select the combobox and then attempt to deselect it by
selecting the checkbox. This is rendered impossible by the combobox
retaining the focus, you cannot even close the form, such is it's grasp on
the focus.

I have found three ways of fixing this problem.

a) Remove the binding to Bar (a bit obvious)
b) Remove the binding to DateTime
c) Make the DateTimePicker visible !?!

I'm currently running Win2k. And .NET 2.00, I think 1.1 has the same
problem.
Code is below.

// SEARCH TAGS: Combobox Focus Bug Binding Datetimepicker. Value
DateTimePicker. Visible

// CODE BEGINS

using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;

namespace WindowsApplicat ion6
{
public class Bar
{
public Bar()
{
}
}

public class Foo
{
private Bar m_Bar = new Bar();
private DateTime m_DateTime = DateTime.Now;

public Foo()
{
}

public Bar Bar
{
get
{
return m_Bar;
}
set
{
m_Bar = value;
}
}

public DateTime DateTime
{
get
{
return m_DateTime;
}
set
{
m_DateTime = value;
}
}
}

public class TestBugControl : UserControl
{
public TestBugControl( )
{
InitializeCompo nent();
}

public void InitializeData( IList types)
{
this.cBoxType.D ataSource = types;
}

public void BindFoo(Foo foo)
{
this.cBoxType.D ataBindings.Add ("SelectedItem" , foo, "Bar");
this.dtStart.Da taBindings.Add( "Value", foo, "DateTime") ;
}

/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be disposed;
otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#region Component Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.checkBox1 = new System.Windows. Forms.CheckBox( );
this.cBoxType = new System.Windows. Forms.ComboBox( );
this.dtStart = new System.Windows. Forms.DateTimeP icker();
this.SuspendLay out();
//
// checkBox1
//
this.checkBox1. AutoSize = true;
this.checkBox1. Location = new System.Drawing. Point(14, 5);
this.checkBox1. Name = "checkBox1" ;
this.checkBox1. Size = new System.Drawing. Size(97, 20);
this.checkBox1. TabIndex = 0;
this.checkBox1. Text = "checkBox1" ;
this.checkBox1. UseVisualStyleB ackColor = true;
//
// cBoxType
//
this.cBoxType.F ormattingEnable d = true;
this.cBoxType.L ocation = new System.Drawing. Point(117, 3);
this.cBoxType.N ame = "cBoxType";
this.cBoxType.S ize = new System.Drawing. Size(165, 24);
this.cBoxType.T abIndex = 1;
//
// dtStart
//
this.dtStart.Lo cation = new System.Drawing. Point(117, 40);
this.dtStart.Na me = "dtStart";
this.dtStart.Si ze = new System.Drawing. Size(165, 23);
this.dtStart.Ta bIndex = 2;
this.dtStart.Vi sible = false;
//
// TestBugControl
//
this.AutoScaleD imensions = new System.Drawing. SizeF(8F, 16F);
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
this.Controls.A dd(this.dtStart );
this.Controls.A dd(this.cBoxTyp e);
this.Controls.A dd(this.checkBo x1);
this.Font = new System.Drawing. Font("Verdana", 9.75F,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
((byte)(0)));
this.Margin = new System.Windows. Forms.Padding(4 );
this.Name = "TestBugControl ";
this.Size = new System.Drawing. Size(285, 66);
this.ResumeLayo ut(false);
this.PerformLay out();

}

#endregion

private System.Windows. Forms.CheckBox checkBox1;
private System.Windows. Forms.ComboBox cBoxType;
private System.Windows. Forms.DateTimeP icker dtStart;
}

public class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
this.Load += new EventHandler(Fo rm1_Load);
}

void Form1_Load(obje ct sender, EventArgs e)
{
InitializeContr ol();
}

public void InitializeContr ol()
{
TestBugControl control = new TestBugControl( );
IList list = new ArrayList();
for (int i = 0; i < 10; i++)
{
list.Add(new Bar());
}
control.Initial izeData(list);
control.BindFoo (new Foo());
this.Controls.A dd(control);
}

/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be disposed;
otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.components = new System.Componen tModel.Containe r();
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
this.Text = "Form1";
}

#endregion
}

static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Ena bleVisualStyles ();
Application.Set CompatibleTextR enderingDefault (false);
Application.Run (new Form1());
}
}
}
Mar 13 '07 #1
3 7515
VJ
I tried adding your user control add design time, and then assigning values
at load it worked, without any of your workaround.. Create, add the control
to form and then assign values to it. That order also works. Some how
creating, assigning and adding to Form fails.. Interesting situation, I will
see if I can find time later to work this. Let me know if you learn anything
new..

Bottom of problem, maybe Microsoft can answer?..

VJ

"Simon Tamman" <i_************ *************** *******@NOSPAMh otmail.com>
wrote in message news:st******** *****@newsfe4-gui.ntli.net...
I've come across an interesting bug.
I have workarounds but i'd like to know the root of the problem. I've
stripped it down into a short file and hope someone might have an idea
about
what's going on.

It's a simple program that loads a control onto a form and binds "Foo"
against a combobox ("SelectedItem" ) for it's "Bar" property and a
datetimepicker ("Value") for it's "DateTime" property. The
DateTimePicker. Visible value is set to false.
Once it's loaded up, select the combobox and then attempt to deselect it
by
selecting the checkbox. This is rendered impossible by the combobox
retaining the focus, you cannot even close the form, such is it's grasp on
the focus.

I have found three ways of fixing this problem.

a) Remove the binding to Bar (a bit obvious)
b) Remove the binding to DateTime
c) Make the DateTimePicker visible !?!

I'm currently running Win2k. And .NET 2.00, I think 1.1 has the same
problem.
Code is below.

// SEARCH TAGS: Combobox Focus Bug Binding Datetimepicker. Value
DateTimePicker. Visible

// CODE BEGINS

using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;

namespace WindowsApplicat ion6
{
public class Bar
{
public Bar()
{
}
}

public class Foo
{
private Bar m_Bar = new Bar();
private DateTime m_DateTime = DateTime.Now;

public Foo()
{
}

public Bar Bar
{
get
{
return m_Bar;
}
set
{
m_Bar = value;
}
}

public DateTime DateTime
{
get
{
return m_DateTime;
}
set
{
m_DateTime = value;
}
}
}

public class TestBugControl : UserControl
{
public TestBugControl( )
{
InitializeCompo nent();
}

public void InitializeData( IList types)
{
this.cBoxType.D ataSource = types;
}

public void BindFoo(Foo foo)
{
this.cBoxType.D ataBindings.Add ("SelectedItem" , foo, "Bar");
this.dtStart.Da taBindings.Add( "Value", foo, "DateTime") ;
}

/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be disposed;
otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#region Component Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.checkBox1 = new System.Windows. Forms.CheckBox( );
this.cBoxType = new System.Windows. Forms.ComboBox( );
this.dtStart = new System.Windows. Forms.DateTimeP icker();
this.SuspendLay out();
//
// checkBox1
//
this.checkBox1. AutoSize = true;
this.checkBox1. Location = new System.Drawing. Point(14, 5);
this.checkBox1. Name = "checkBox1" ;
this.checkBox1. Size = new System.Drawing. Size(97, 20);
this.checkBox1. TabIndex = 0;
this.checkBox1. Text = "checkBox1" ;
this.checkBox1. UseVisualStyleB ackColor = true;
//
// cBoxType
//
this.cBoxType.F ormattingEnable d = true;
this.cBoxType.L ocation = new System.Drawing. Point(117, 3);
this.cBoxType.N ame = "cBoxType";
this.cBoxType.S ize = new System.Drawing. Size(165, 24);
this.cBoxType.T abIndex = 1;
//
// dtStart
//
this.dtStart.Lo cation = new System.Drawing. Point(117, 40);
this.dtStart.Na me = "dtStart";
this.dtStart.Si ze = new System.Drawing. Size(165, 23);
this.dtStart.Ta bIndex = 2;
this.dtStart.Vi sible = false;
//
// TestBugControl
//
this.AutoScaleD imensions = new System.Drawing. SizeF(8F, 16F);
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
this.Controls.A dd(this.dtStart );
this.Controls.A dd(this.cBoxTyp e);
this.Controls.A dd(this.checkBo x1);
this.Font = new System.Drawing. Font("Verdana", 9.75F,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
((byte)(0)));
this.Margin = new System.Windows. Forms.Padding(4 );
this.Name = "TestBugControl ";
this.Size = new System.Drawing. Size(285, 66);
this.ResumeLayo ut(false);
this.PerformLay out();

}

#endregion

private System.Windows. Forms.CheckBox checkBox1;
private System.Windows. Forms.ComboBox cBoxType;
private System.Windows. Forms.DateTimeP icker dtStart;
}

public class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
this.Load += new EventHandler(Fo rm1_Load);
}

void Form1_Load(obje ct sender, EventArgs e)
{
InitializeContr ol();
}

public void InitializeContr ol()
{
TestBugControl control = new TestBugControl( );
IList list = new ArrayList();
for (int i = 0; i < 10; i++)
{
list.Add(new Bar());
}
control.Initial izeData(list);
control.BindFoo (new Foo());
this.Controls.A dd(control);
}

/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be disposed;
otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.components = new System.Componen tModel.Containe r();
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
this.Text = "Form1";
}

#endregion
}

static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Ena bleVisualStyles ();
Application.Set CompatibleTextR enderingDefault (false);
Application.Run (new Form1());
}
}
}


Mar 13 '07 #2
Thanks for looking into it VJ. :D It's certainly an interesting one, eh?
Could you post the modifications you made to the code so I can reproduce
your workaround on this side?

I guess M$ could solve the problem but i'm pretty sure someone else must
stumbled across this at some point and researched it as well, has this
already been reported as a bug in the framework or am I bypassing a binding
standard and just writing bad code?
From what I can make out the example is pretty standard, isn't it?

King Regards

Simon

"VJ" <no***********@ yahoo.comwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
I tried adding your user control add design time, and then assigning
values
at load it worked, without any of your workaround.. Create, add the
control
to form and then assign values to it. That order also works. Some how
creating, assigning and adding to Form fails.. Interesting situation, I
will
see if I can find time later to work this. Let me know if you learn
anything
new..

Bottom of problem, maybe Microsoft can answer?..

VJ

"Simon Tamman" <i_************ *************** *******@NOSPAMh otmail.com>
wrote in message news:st******** *****@newsfe4-gui.ntli.net...
I've come across an interesting bug.
I have workarounds but i'd like to know the root of the problem. I've
stripped it down into a short file and hope someone might have an idea
about
what's going on.

It's a simple program that loads a control onto a form and binds "Foo"
against a combobox ("SelectedItem" ) for it's "Bar" property and a
datetimepicker ("Value") for it's "DateTime" property. The
DateTimePicker. Visible value is set to false.
Once it's loaded up, select the combobox and then attempt to deselect it
by
selecting the checkbox. This is rendered impossible by the combobox
retaining the focus, you cannot even close the form, such is it's grasp
on
the focus.

I have found three ways of fixing this problem.

a) Remove the binding to Bar (a bit obvious)
b) Remove the binding to DateTime
c) Make the DateTimePicker visible !?!

I'm currently running Win2k. And .NET 2.00, I think 1.1 has the same
problem.
Code is below.

// SEARCH TAGS: Combobox Focus Bug Binding Datetimepicker. Value
DateTimePicker. Visible

// CODE BEGINS

using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;

namespace WindowsApplicat ion6
{
public class Bar
{
public Bar()
{
}
}

public class Foo
{
private Bar m_Bar = new Bar();
private DateTime m_DateTime = DateTime.Now;

public Foo()
{
}

public Bar Bar
{
get
{
return m_Bar;
}
set
{
m_Bar = value;
}
}

public DateTime DateTime
{
get
{
return m_DateTime;
}
set
{
m_DateTime = value;
}
}
}

public class TestBugControl : UserControl
{
public TestBugControl( )
{
InitializeCompo nent();
}

public void InitializeData( IList types)
{
this.cBoxType.D ataSource = types;
}

public void BindFoo(Foo foo)
{
this.cBoxType.D ataBindings.Add ("SelectedItem" , foo, "Bar");
this.dtStart.Da taBindings.Add( "Value", foo, "DateTime") ;
}

/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be
disposed;
otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#region Component Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.checkBox1 = new System.Windows. Forms.CheckBox( );
this.cBoxType = new System.Windows. Forms.ComboBox( );
this.dtStart = new System.Windows. Forms.DateTimeP icker();
this.SuspendLay out();
//
// checkBox1
//
this.checkBox1. AutoSize = true;
this.checkBox1. Location = new System.Drawing. Point(14, 5);
this.checkBox1. Name = "checkBox1" ;
this.checkBox1. Size = new System.Drawing. Size(97, 20);
this.checkBox1. TabIndex = 0;
this.checkBox1. Text = "checkBox1" ;
this.checkBox1. UseVisualStyleB ackColor = true;
//
// cBoxType
//
this.cBoxType.F ormattingEnable d = true;
this.cBoxType.L ocation = new System.Drawing. Point(117, 3);
this.cBoxType.N ame = "cBoxType";
this.cBoxType.S ize = new System.Drawing. Size(165, 24);
this.cBoxType.T abIndex = 1;
//
// dtStart
//
this.dtStart.Lo cation = new System.Drawing. Point(117, 40);
this.dtStart.Na me = "dtStart";
this.dtStart.Si ze = new System.Drawing. Size(165, 23);
this.dtStart.Ta bIndex = 2;
this.dtStart.Vi sible = false;
//
// TestBugControl
//
this.AutoScaleD imensions = new System.Drawing. SizeF(8F, 16F);
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
this.Controls.A dd(this.dtStart );
this.Controls.A dd(this.cBoxTyp e);
this.Controls.A dd(this.checkBo x1);
this.Font = new System.Drawing. Font("Verdana", 9.75F,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
((byte)(0)));
this.Margin = new System.Windows. Forms.Padding(4 );
this.Name = "TestBugControl ";
this.Size = new System.Drawing. Size(285, 66);
this.ResumeLayo ut(false);
this.PerformLay out();

}

#endregion

private System.Windows. Forms.CheckBox checkBox1;
private System.Windows. Forms.ComboBox cBoxType;
private System.Windows. Forms.DateTimeP icker dtStart;
}

public class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
this.Load += new EventHandler(Fo rm1_Load);
}

void Form1_Load(obje ct sender, EventArgs e)
{
InitializeContr ol();
}

public void InitializeContr ol()
{
TestBugControl control = new TestBugControl( );
IList list = new ArrayList();
for (int i = 0; i < 10; i++)
{
list.Add(new Bar());
}
control.Initial izeData(list);
control.BindFoo (new Foo());
this.Controls.A dd(control);
}

/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be
disposed;
otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.components = new System.Componen tModel.Containe r();
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
this.Text = "Form1";
}

#endregion
}

static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Ena bleVisualStyles ();
Application.Set CompatibleTextR enderingDefault (false);
Application.Run (new Form1());
}
}
}


Mar 13 '07 #3
That's great, thanks to your changes I was able remove the bug from my main
source code. :D

The order of adding the control to the form before performing the binding
seems to be key.
The values of the controls don't need to be set first and UserControl seems
to be blameless in this occurance.
It may be something to do with the main BindingContext changing perhaps?
(e.g. you bind when the control isn't on the form and then you add the
control to the form) I'm not 100% sure, but thanks for your help
nevertheless.
"VJ" <no***********@ yahoo.comwrote in message
news:O9******** ******@TK2MSFTN GP03.phx.gbl...
yea its very interesting. I have not used binding that much, theory looks
right to me and maps to what I have learned, but as always the
implementation differs a little. so may be so one implemented could
provide
a insight. I have attached a zip file with what I changed, I tried quite a
few.

Binding is very straight forward concept.. I still suspect the UserControl
base class, that is weird. We avoid it at the max. Most we do is use a
control and inherit from there, and use panels if we need multiple
controls
inside..

I did not see this as a bug in Framework. maybe its a hidden feature :-)
just kidding.

VJ

"Simon Tamman" <i_************ *************** *******@NOSPAMh otmail.com>
wrote in message news:7A******** ******@newsfe3-gui.ntli.net...
Thanks for looking into it VJ. :D It's certainly an interesting one, eh?
Could you post the modifications you made to the code so I can reproduce
your workaround on this side?

I guess M$ could solve the problem but i'm pretty sure someone else must
stumbled across this at some point and researched it as well, has this
already been reported as a bug in the framework or am I bypassing a
binding
standard and just writing bad code?
From what I can make out the example is pretty standard, isn't it?

King Regards

Simon

"VJ" <no***********@ yahoo.comwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
I tried adding your user control add design time, and then assigning
values
at load it worked, without any of your workaround.. Create, add the
control
to form and then assign values to it. That order also works. Some how
creating, assigning and adding to Form fails.. Interesting situation, I
will
see if I can find time later to work this. Let me know if you learn
anything
new..

Bottom of problem, maybe Microsoft can answer?..

VJ

"Simon Tamman" <i_************ *************** *******@NOSPAMh otmail.com>
wrote in message news:st******** *****@newsfe4-gui.ntli.net...
I've come across an interesting bug.
I have workarounds but i'd like to know the root of the problem. I've
stripped it down into a short file and hope someone might have an
idea
about
what's going on.

It's a simple program that loads a control onto a form and binds
"Foo"
against a combobox ("SelectedItem" ) for it's "Bar" property and a
datetimepicker ("Value") for it's "DateTime" property. The
DateTimePicker. Visible value is set to false.
Once it's loaded up, select the combobox and then attempt to deselect
it
by
selecting the checkbox. This is rendered impossible by the combobox
retaining the focus, you cannot even close the form, such is it's
grasp
on
the focus.

I have found three ways of fixing this problem.

a) Remove the binding to Bar (a bit obvious)
b) Remove the binding to DateTime
c) Make the DateTimePicker visible !?!

I'm currently running Win2k. And .NET 2.00, I think 1.1 has the same
problem.
Code is below.

// SEARCH TAGS: Combobox Focus Bug Binding Datetimepicker. Value
DateTimePicker. Visible

// CODE BEGINS

using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;

namespace WindowsApplicat ion6
{
public class Bar
{
public Bar()
{
}
}

public class Foo
{
private Bar m_Bar = new Bar();
private DateTime m_DateTime = DateTime.Now;

public Foo()
{
}

public Bar Bar
{
get
{
return m_Bar;
}
set
{
m_Bar = value;
}
}

public DateTime DateTime
{
get
{
return m_DateTime;
}
set
{
m_DateTime = value;
}
}
}

public class TestBugControl : UserControl
{
public TestBugControl( )
{
InitializeCompo nent();
}

public void InitializeData( IList types)
{
this.cBoxType.D ataSource = types;
}

public void BindFoo(Foo foo)
{
this.cBoxType.D ataBindings.Add ("SelectedItem" , foo, "Bar");
this.dtStart.Da taBindings.Add( "Value", foo, "DateTime") ;
}

/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be
disposed;
otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#region Component Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.checkBox1 = new System.Windows. Forms.CheckBox( );
this.cBoxType = new System.Windows. Forms.ComboBox( );
this.dtStart = new System.Windows. Forms.DateTimeP icker();
this.SuspendLay out();
//
// checkBox1
//
this.checkBox1. AutoSize = true;
this.checkBox1. Location = new System.Drawing. Point(14, 5);
this.checkBox1. Name = "checkBox1" ;
this.checkBox1. Size = new System.Drawing. Size(97, 20);
this.checkBox1. TabIndex = 0;
this.checkBox1. Text = "checkBox1" ;
this.checkBox1. UseVisualStyleB ackColor = true;
//
// cBoxType
//
this.cBoxType.F ormattingEnable d = true;
this.cBoxType.L ocation = new System.Drawing. Point(117, 3);
this.cBoxType.N ame = "cBoxType";
this.cBoxType.S ize = new System.Drawing. Size(165, 24);
this.cBoxType.T abIndex = 1;
//
// dtStart
//
this.dtStart.Lo cation = new System.Drawing. Point(117, 40);
this.dtStart.Na me = "dtStart";
this.dtStart.Si ze = new System.Drawing. Size(165, 23);
this.dtStart.Ta bIndex = 2;
this.dtStart.Vi sible = false;
//
// TestBugControl
//
this.AutoScaleD imensions = new System.Drawing. SizeF(8F, 16F);
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
this.Controls.A dd(this.dtStart );
this.Controls.A dd(this.cBoxTyp e);
this.Controls.A dd(this.checkBo x1);
this.Font = new System.Drawing. Font("Verdana", 9.75F,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
((byte)(0)));
this.Margin = new System.Windows. Forms.Padding(4 );
this.Name = "TestBugControl ";
this.Size = new System.Drawing. Size(285, 66);
this.ResumeLayo ut(false);
this.PerformLay out();

}

#endregion

private System.Windows. Forms.CheckBox checkBox1;
private System.Windows. Forms.ComboBox cBoxType;
private System.Windows. Forms.DateTimeP icker dtStart;
}

public class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
this.Load += new EventHandler(Fo rm1_Load);
}

void Form1_Load(obje ct sender, EventArgs e)
{
InitializeContr ol();
}

public void InitializeContr ol()
{
TestBugControl control = new TestBugControl( );
IList list = new ArrayList();
for (int i = 0; i < 10; i++)
{
list.Add(new Bar());
}
control.Initial izeData(list);
control.BindFoo (new Foo());
this.Controls.A dd(control);
}

/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be
disposed;
otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.components = new System.Componen tModel.Containe r();
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
this.Text = "Form1";
}

#endregion
}

static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Ena bleVisualStyles ();
Application.Set CompatibleTextR enderingDefault (false);
Application.Run (new Form1());
}
}
}






Mar 15 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1700
by: Richard Hallgren | last post by:
Hi, In Windows Forms the usual approach to add a combobox in a datagrid involves adding a single combobox to the DataGrid.Controls, and then selectively displaying it as needed when a combobox cell becomes the currentcell. However I'm looking for a way to add a control to a cell in each row from the actually set up and source binding of the datagrid. I'd like to have the combobox visible at all times (kind of hard to know that one...
0
2175
by: Sumit | last post by:
Hi all, I have a datetimepicker on my windows form. When the user selects it i check whether the date entered is a Sunday or not & if its not a sunday i want that the control remains on the DateTimePicker & the DateTimePicker is displayed in its expaned form (i.e displaying the calendar). If i do a datetimepicker.focus(), then the focus goes to the datetimepicker but the user who is using it might ignore the focus as
0
2016
by: Uchiha Jax | last post by:
When using a strongly typed dataset (generated from the Visual Studio IDE from an XSD file) and databinding I get a really odd error when binding to both a combox and a datetimepicker. I bind like the following: //// tDs is the strongly typed dataset, //// tDs.TheTask returns a strongly typed row from one of the tables. /// GetBindingTaskTypes() returns the types I want to use as a datasource in an arraylist.
3
6383
by: Charlie | last post by:
In the top portion of the DateTimePicker, where the value of the date is displayed, how can I detect whether the month or day or year is currently focused, or, if ShowCheckBox = True, whether the checkbox is focused?
30
4594
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a corresponding field in the lookup table. In my data table we store the ID in what I will call the 'key' field. == Description of the desired operation:
2
8668
by: shumaker | last post by:
I have a combobox that is very much like the one found in the RSS project here: http://msdn.microsoft.com/vstudio/express/visualCSharp/learning/ My projectNameComboBox basically is filled with a list of values from a table, and as the user selects values, a datagrid displays related records from another table because it is bound via FK relationship. My table: /****** Object: Table . Script Date: 06/19/2006
1
2785
by: Robinson | last post by:
Hi, I want a user control I have to "dissapear" when it loses the focus. The control is made up of some other controls however, a text box, a button and a DateTimePicker. In order to effect this behaviour I'm handling the "LostFocus" event on each of these controls and checking to see if any of them have the focus; if so, cancelling the "lostfocus" of the control as a whole. The problem is that the DateTimePicker when activated...
1
3237
by: Kevin | last post by:
I have put a VS2005 sample project up here: http://www.kevinandkiran.com/CSharpApplication.zip (its only 50k) Basically I have a class that contains a date property, which is initialised to 1/1/1970. I create a project datasource from this and then drag my class onto my form which binds my property to a datetimepicker. However when I set the bindingsource to be an instance of my class at runtime I get the following exception:
1
2988
by: venkatraotammineiii | last post by:
Dear all, I am working C#.net2005.I Have problem that is i have one datetimepicker and combobox.now i have msaccess databse.in that database i have datatime field.but i need to get datetime into datetimepicker when user click the datetimepicker the data has to come form database and it has to set date form database.based on that date i need get persons are in combobox. means once i click datetimepicker it need to access the data from...
0
8748
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9393
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9248
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9164
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9092
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6695
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6000
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4506
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2622
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.