ToolStripTextBox, ToolStripComboBox not automated - winforms

In UI Automation, when automating the toolstrip items we are facing an issue which is described below
I am adding toolstrip items as follows
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripButton1,
this.toolStripButton2,
this.toolStripComboBox1,
this.toolStripButton3});
When running the UI Automation(System.Windows.Automation), UI automation finds the controls till toolStripButton2 (i.e) controls on the left side of toolstripcombobox is getting recognized but on the controls on the right side.(If i make the combobox to go the right most control everything works fine)
Note: In Inspect.exe tool from windows kits, all the controls are shown but when trying to access the last toolStripButton3 returns null.
Here i have attached the simplified code, the buttonCollection is expected to get 3 buttons but it gets only two in my case.
AutomationElement toolstrip = viewTab.FindFirst(TreeScope.Children,
new PropertyCondition(AutomationElement.AutomationIdProperty, "toolStrip1"));
AutomationElementCollection buttonCollection = toolstrip.FindAll(TreeScope.Children,
new PropertyCondition(AutomationElement.LocalizedControlTypeProperty, "button"));
Both ToolStripTextBox and ToolStripComboBox are showing the same behavior.
I would like know what is going wrong my approach.

I've posted one approach which would allow you to access all the buttons, in response to your question at https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/2363de9f-3bf0-48dc-a914-1eef5bcf1482/toolstriptextbox-toolstripcombobox-not-automated?forum=windowsaccessibilityandautomation.
Thanks,
Guy

Related

Syncfusion v17 Winforms TreeView controls has odd behavior

At work we are upgrading numerous of our applications to run on .NET Core. We upgraded one of our winforms apps which uses SyncFusion controls and we started seeing a strange behavior.
If you create a TreeView control with the parent item not showing a check box, but have the children show a checkbox. When you click the first child it checks all the children under that parent.
Thinking that we had clearly done something wrong in our code, I downloaded the demo apps from Github. Their CheckboxBinding demo seemed similar (parent items with child items with checkboxes). I updated the code to not show the checkbox on the parent items and ran.
To my surprise, we get the exact same behavior.
Has anyone run into this with SyncFusion TreeView control?
We could observe that you are enabling checkbox for child item and disabled for parent item. But while you checking the first child item, it automatically selects all child . We too checked in your provided example, but we could able to observe that on selecting the item in checkbox , it does select only that particular checkbox item and not all other items. Please find the video for the same from following
Video:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/Checkstate_Treeview-949457604
So kindly check the video and confirm us whether our understanding on the reported behavior is correct. If not, please send us the video that shows the exact issue, it would be helpful for us to proceed on it further. We have ensured it in 17.4.0.55v
Regards,
Vijayalakshmi VR

Tree node selection in winform app not working properly

I am working in Winform app (ticketing app) where people can create support ticket,close etc.
once you select a particular tree node in left pane (either manually or programatically) it's associated control/view gets displayed in right pane of form.
In few scenarios, even though the particular node is getting selected properly (though code) it's associated control not getting displayed/loaded. To brief,
Under root node, I have a open incident, once I close the incident it disappears from opened section and gets added to history section under treeview.
once click on "create incident" button a new tree node gets created with new ticket number and it's associated control gets displayed on right side of form.
So problem is, if I close a open incident and then click on "create incident"; even though new node getting created and it's associated control getting loaded but the control not getting displayed; instead the closed incident view only shown.
Somehow, the new nodes control getting hidden/jammed inside.
I am new to winform/treeview control.I debugged to see if anything going wrong but couldn't find any; neither Google'ng helped me.
Anyone here have any idea what's going wrong (OR) have you faced the same issue. Please help and let me know how to solve it.
PS: Sorry can't post any code and I know without code it's bit difficult to answer but if you can provide any pointer that would help me too.
When you select a treenode and the associated control is not getting loaded, one of four things is probably happening:
The code to view the control is not executed,
The code to view the control is being executed but does not work properly,
The code to view the control is working properly but it is being executed again or hide the control, or
The code to view the control is working properly but some other code is being executed to hide the control.
Set breakpoints in the code to view the control to see which of these is the problem. Once you have narrowed it down, it should be easier to fix.

Weird scrollbar UI in hosted WPF composite control

My windows forms application hosts AvalonEdit (the composite WPF control in question) in one of its forms to cater to its text editing requirements. Here's the code I use:
WPFHost = gcnew ElementHost();
TextField = gcnew AvalonEdit::TextEditor();
WPFHost->Dock = DockStyle::Fill;
WPFHost->Child = TextField;
TextField->Options->AllowScrollBelowDocument = false;
TextField->Options->EnableEmailHyperlinks = false;
TextField->Options->EnableHyperlinks = true;
TextField->Options->RequireControlModifierForHyperlinkClick = true;
TextField->ShowLineNumbers = true;
ContainerControl->Controls->Add(WPFHost); // the container is a panel
The code compiles and executes fine, except for the scrollbars - http://dl.dropbox.com/u/2584752/avalonEditBug.png . Right clicking on what's left of the bar raises an ArgumentOutOfRange exception.
Strangely, I wasn't able to reproduce the issue when I tried hosting the control in a newly created sample project. 'mI using the latest build of the text editor and have all the requisite assemblies installed.
EDIT: Wrapping the editor in a usercontrol doesn't help either.
You say that the control works fine in a new/blank project but fails in the one you need makes me wonder about conflicts more than anything. In the project you're really wanting compared to the project it worked in what are the differences? .NET version? Referencing an assembly from a directory in one but out of the GAC in another?
It's hard to say that the control is messing up for you when you've got it working elsewhere, so the only thing I can suggest is just dive deep into the differences of the two projects.
Good luck.
This looks like a layout error to me. Maybe WPFHost measures the TextField unexpectedly.
I can suggest setting specific Width and Height on the TextField itself. If this fixes the problem you can adjust those as the size of the WPFHost control changes or try setting the MaxHeight/Width, sometimes they help and save some code for Width/Height updates.
try to create a WPF grid as a child of ElementHost, and place the editor inside that grid. On Other way, is to create an UserControl have the editor in that control and use the control inside your Winform app. Such approach helped me a couple of times.
I've implemented a workaround for the issue as mentioned in this thread [ Synchronizing a WPF ScrollViewer with a WinForms ScrollBar ].

Adding controls causes silverlight to hang

I have a very strange issue that I'm finding it extremely hard to debug, thus I once more turn to the SO community. :-)
First a bit on my setup (note! I'm new to silverlight, just learning by doing, so my entire premise might be wrong!):
I have some root nodes (forms) under which are some leaves (questions).
Now, I simply want to show / hide the questions depending on which form is currently selected - fairly easy.
I do the following:
A number of controls are added to a LayoutControl (I'm using the DeveloperExpress components)
When you select another form, the created controls are saved in a list on the previously selected form
When you select a form, the list of controls is iterated through, and each element is added to my layoutcontrol again
When I save the elements in the list on a Form I make sure to first .Remove() them from their parent to make sure there are no issues with that.
And, this works.
If I have 1 or controls.
If I have MORE than that, everything is added as usual, no exception is thrown - but Silverlight apparently does an infinite loop somehow? No matter if I run it in IE or Chrome, it just crashes the browser! (Or, I guess, the browser plugin).
I've tried pausing the debugger during this to see where the problem is, but it just stops in "external code".
I don't think a code sample will do much good, but here's the two methods that save and load the elements: (Note: AddControl is a method I've defined - it wraps the element in another control to provide a bit of functionality. Likewise .MyChildren removes the control from the wrapper using .Remove() and returns it)
private void LoadElementsFromCurrentForm()
{
foreach (var child in _currentForm.Elements)
{
layoutControl1.AddControl(child);
}
}
private void SetElementsOnCurrentForm()
{
_currentForm.Elements.Clear();
foreach (var child in layoutControl1.MyChildren)
{
_currentForm.Elements.Add(child);
}
}
How do I even go about debugging this!?
I don't know if it matters, but all these controls have a unique name as well.
Regards
Søren
To take full advantage of Silverlight you should try to use XAML to do the markup of design.
If you want to make a list of questions use e Listbox or ItemsControl.
Then you can style each item in the list to "look right".
If you bind the listbox to ObservableCollection you just add or remove in the list and the gui will be updated according to whats in your list.
Take a look at MVVM which works really good with Silverlight.

WPF Combobox bug when form allowtransparency=true

I have found the following in WPF:
I have a form with AllowTransparency=true. Inside the form I put a Combobox.
I add some items to the combobox.
I run this application and click on the combobox. At first it does not seem to appear at all. On closer inspection (after adding more items) I see that it is actually appearing behind the form. If I add enough items it become visible from behind the form.
If I just change AllowTransparency=false, then all is fine.
This looks like a bug in WPF (3.5 SP1).
Any one know of a workaround for this?
Go to
https://connect.microsoft.com/dashboard/?wa=wsignin1.0
submit your feedback after searching #
https://connect.microsoft.com/VisualStudio
https://connect.microsoft.com/VisualStudio/feedback/CreateFeedbackForm.aspx?FeedbackFormConfigurationID=1160&FeedbackType=1
and mention steps to reproduce.
There was an update of 3.5sp1 but you could test,but I doubt
http://www.microsoft.com/downloads/details.aspx?familyid=6c095bba-6100-4ec9-9c54-6450b0212565&displaylang=en
AllowTransparency is slow and buggy and shouldn't be used - it's a great way to run into bug in various display drivers.
You can get almost anything you like without using AllowTrasparency, take a look at this post for examples:
http://blogs.msdn.com/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx

Resources