473,324 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

ActiveX ruins Validation events.

I am using an ActiveX control in a .NET application which I put on a
form. I have another .NET control on that form that handles the
Validating event. The method that handles the Validating event, shows a
message box and sets e.Cancel = True. When I click any other control in
the form, the message box shows and the focus returns to the control
that handled the Validating event. The problem happens when I click on
the ActiveX control. The ActiveX control gets the focus and the focus
doesn't return to the validated control and no message box is
displayed. With a different ActiveX control the message was displayed,
but the focus didn't return to the validated control.

I reproduced the bug in a small application. In that application I
wrote an ActiveX in VB 6 that has an edit box. In a c# .NET application
I put on a form the ActiveX and 2 text boxes. One text box is validated
and is called textBoxValidated and the other one is not vaildated and
is called textBoxRegular (the regular text box is used to demonstrate
regular validating behaviour) . In this form, the first time you click
on the ActiveX, it works ok, but the 2nd time it doens't work ok
Here is the code of the form:

"
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication5
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private AxProject1.AxUserControl1 axUserControl11;
private System.Windows.Forms.TextBox textBoxValidated;
private System.Windows.Forms.TextBox textBoxRegular;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#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 InitializeComponent()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(Form1));
this.textBoxValidated = new System.Windows.Forms.TextBox();
this.axUserControl11 = new AxProject1.AxUserControl1();
this.textBoxRegular = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.a xUserControl11)).BeginInit();
this.SuspendLayout();
//
// textBoxValidated
//
this.textBoxValidated.Location = new System.Drawing.Point(448, 72);
this.textBoxValidated.Name = "textBoxValidated";
this.textBoxValidated.TabIndex = 2;
this.textBoxValidated.Text = "validated text box";
this.textBoxValidated.Validating += new
System.ComponentModel.CancelEventHandler(this.text Box1_Validating);
//
// axUserControl11
//
this.axUserControl11.Enabled = true;
this.axUserControl11.Location = new System.Drawing.Point(128, 160);
this.axUserControl11.Name = "axUserControl11";
this.axUserControl11.OcxState =
((System.Windows.Forms.AxHost.State)(resources.Get Object("axUserControl11.OcxState")));
this.axUserControl11.Size = new System.Drawing.Size(320, 240);
this.axUserControl11.TabIndex = 3;
//
// textBoxRegular
//
this.textBoxRegular.Location = new System.Drawing.Point(544, 152);
this.textBoxRegular.Name = "textBoxRegular";
this.textBoxRegular.Size = new System.Drawing.Size(88, 20);
this.textBoxRegular.TabIndex = 4;
this.textBoxRegular.Text = "Regular text box";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(824, 470);
this.Controls.Add(this.textBoxRegular);
this.Controls.Add(this.axUserControl11);
this.Controls.Add(this.textBoxValidated);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.a xUserControl11)).EndInit();
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void textBox1_Validating(object sender,
System.ComponentModel.CancelEventArgs e)
{

MessageBox.Show("DAN:(");
e.Cancel=true;
}

private void button1_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
}
}
"
Does any one know how to overcome this bug?

Thanks ,
Dan & Zeev.

Nov 17 '05 #1
0 1333

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

Similar topics

11
by: dw85745 | last post by:
PROBLEMS I Haven't solved: 1. Timing issue between real-time server #1 and my drawing tools. Will moving the tools (currently within module) to an ActiveX (exe or DLL) solve the problem or...
2
by: Bill | last post by:
I have a VB6 ActiveX EXE app that generates events that I would like to handle in a C# application. The events in the VB app are defined like: Public Event SometingHappened(what As String) ...
5
by: Sagaert Johan | last post by:
hi I have the following problem: I have a C# application that uses an activeX . I installed the application and the NET 1.1 Runtimes on a clean pc When running the application i discover...
4
by: AIM48 | last post by:
Hi. We have a framework that we work with for our project. So far we have had very good success – basically the frame work wraps many day to day tasks so that they are all included in the...
5
by: Richard Brown | last post by:
Ok, I've been looking through the .NET SDK docs and stuff. I'm wondering if you can provide a control extender that does generic validation or functionality just by dropping it on the form. For...
0
by: Peter | last post by:
I have a VB6 program which can receive Keydown events on an ActiveX control. The ActiveX control can't fire keydown events so I put a picturebox below the ActiveX control. I write codes in...
0
by: swong4 | last post by:
Hi all, I am trying to use an ActiveX control on the server-side of an ASP.NET 2.0 application written in C#. The ActiveX control is a 3rd-party interface to a data feed used by my application...
23
by: Galen Somerville | last post by:
A VB6 ActiveX.exe raises an event which is seen by the VB6 App. Same setup in VB2005. The event to be raised is in form frmSweep. As in VB6, frmSweep is hidden when the events take place. I...
0
by: miarfej | last post by:
Hi to all.. i am just new here, hoping to find some suggestions. I am writing a code in VC++. It is about creating an activeX control using MFC. This control exposes the properties and methods of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.