An user control inherited from TextBox can not be found by White

Mar 9, 2009 at 6:07 PM
Hello,

if anybody can help me to undestand why in case of System.Windows.Forms.TextBox's  AutomationId is equal to the textbox name 
however when we have custom componenet that Inherits from System.Windows.Forms.TextBox  AutomationID is run-time assigned number.

In result you can easily find any textbox on form but you can not find any custom component that inherits from System.Windows.Forms.TextBox.

That is a huge limation that prevent to find and use any textbox on form but original Windows.Forms one.

Please would you explain what can be done in Custom Component Control to make it visible its inherited NAME property to appear in AutomationID?

Thanks.
Zoran.

 

 

 

Mar 10, 2009 at 9:31 PM
Hello,

when I use UISpy or VisualUIAVerify it looked that those tools are completly confused by a component that inherits from regular MS control.
AutomationID is always dynamic number. I tried search by text and it could not find comtrol as well.
Are White and UI Automation are limited to only base MS controls?

Thanks.
Zoran.
Coordinator
Mar 11, 2009 at 4:23 AM
zmilanovic,
there is no reason the subclasses of winform controls to not have automationIds. I have used them in the past.
do you have some sample code where you can illustrate this problem.
Mar 11, 2009 at 9:34 PM
Hello Vivek,

I found what is probelm!

If you create component with VS designer it creates partial class with two contructors: one with argument and other without.
When you drop the compenent to the form it uses constrcutor with argument. And that is problem.

Partial

 

Class DxTextEditComp

 

 

Inherits DevExpress.XtraEditors.TextEdit

 

<System.Diagnostics.DebuggerNonUserCode()> _

 

Public Sub New(ByVal Container As System.ComponentModel.IContainer)

 

 

MyClass.New()

 

 

'Required for Windows.Forms Class Composition Designer support

 

 

'Container.Add(Me)    <<<<<<<<<<<<<<<<<<<<<<<<<<<<PROBLEM

 

 

End Sub

I commented line'Container.Add(Me)   in that method and after that White and UIA could see AutomationID as component/control name.
It looks like everything works fine and I have no probem after commenting that line.

Anu idea what is going on here.

Thanks.
Zoran.


Coordinator
Mar 25, 2009 at 11:08 AM
can you send me the .csproj with all the code. it would easier that way.
Mar 25, 2009 at 4:28 PM

Hello,

It i so simple project.
Create in C# component from class like
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace TestUIAWhite
{
class ComponentbyClass : TextBox
{}
}

Create the another component using VS designer componenet template and make it inherits from TextBox.

 

using

 

System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;

 

 

namespace TestUIAWhite

 

{

 

public partial class ComponentbyDesigner : TextBox
{

 

 

public ComponentbyDesigner()

 

{

InitializeComponent();

}

public ComponentbyDesigner(IContainer container)

 

{

container.Add(

this);

 

InitializeComponent();

}

}

}

 

 

 

Now add both components to Window form.
Use UISpy to check their AutomationIDs.

In the first case we have control name and in second we have useless dynamic number.

The solution for second case I already posted. This line has to be commented.

 

 

//container.Add(this);

 

 

 


Thanks.
Zoran.

 

 

 


 

Apr 20, 2009 at 3:34 PM
Hello Vivek,
 
sorry for delay.
This zip file with project and screenshot from UIVerify.
 
Again I am not sure if commenting line in designer code, that makes UI works, can cause trouble somewhere else.
Please see my coment in designer code.
 
Please rename txt to zip.
 
Thanks.
Zoran.

On Wed, Mar 25, 2009 at 5:08 AM, viveksingh <notifications@codeplex.com> wrote:

From: viveksingh

can you send me the .csproj with all the code. it would easier that way.

Read the full discussion online.

To add a post to this discussion, reply to this email (white@discussions.codeplex.com)

To start a new discussion for this project, email white@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


May 12, 2009 at 6:48 PM

@zmilanovic

Thank-you for posting your solution, I too was beating my head against the wall looking for an answer to this problem on a custom control derived from Textbox.

I need to understand what the implications are of commenting out that line, //container.Add(this);

And then I hope I am done with that issue.   Thank-you.

Coordinator
May 25, 2009 at 6:09 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.