02-09-2011 10:59 AM
I have a combo box that I am using to input data into a table. I dynamically change the position and size of the box according to the size of the cell selected. Most of the time, this works perfectly well. When the user selects the drop down, the drop down text box appears directly under the control. However, when the control is placed near the right edge of the screen, the drop down text box is offset too far to the left (See attached screen shot).
I have looked for properties or methods that would allow me to directly control the positioning of the drop down text box, but have not found anything. If this was in .NET, the combo box text drop down box behavior is set to just display the text box under the control even if the text goes off the right of the screen. This behavior can be manipulated by creating an over-ride for the WndProc in System.Windows.Forms.ComboBox. I don't really want to create a custom control in .NET and try to import it into my project. I believe that something similar to this already exists in the back end code of LabVIEW; however, I have not been able to figure out how to manipulate the application controls vi's to grant me access to this part of the combo box control.
Any suggestions are welcome. The behavior of the drop down box is quite close to what I need; however, it just seems that the offsets are just a little out of tune.
Thanks,
Drew
02-09-2011 12:08 PM
Can not check with LV at the moment, but my SWAG (stupid wild-axx guess) is that the Modern or Classic style combo box would give you better results. You may be able to tweak the appearance since I like the system look much better.
When you do the test, make sure you have 'Values Match Items' checked if you try to replace the combo box, I had LV crash when converting one style combo box to another.
02-09-2011 12:28 PM
I have tried several different drop down controls and get the same results. I will double check the NI combo boxes to see if anything can be done with them. I did look at the NI stylized combo box and it did not have any more options available than the system combo box.
02-09-2011 01:26 PM - edited 02-09-2011 01:27 PM
So I looked at the available combo boxes that I have, modern, system, NI.com theme, and Metalic theme. I did not pull the classic combo box out, but I would venture a guess that the behavior is the same. For each case, when the dropdown is too close to the edge of the screen, it is offset to the left a lot further than I would anticipate. The example here is a lot closer to the functionality that I would expect to see from this control. The other option is to expose the dropdown width and position properties so that the developer can choose how the drop down operates.
02-09-2011 02:22 PM
I was able to test on my machine with somewhat similar results.
System and Classic showed consistently bad behavior, even with short strings. The modern Combo box was more tolerant, but still showed the annoying behavior when the width of the widest string got too close to the box width. I don't suppose you want a bunch of white space in that table.
yuk, what a pain. Hope you don't have to roll your own.
02-09-2011 02:34 PM
My suspicion is that this is actually a bug in the handler for this control type. It's almost like the offset of the drop down location is referenced from the right corner of the control and not calculated back from the right edge of the workspace.
I think I might have a chat with support on this one.
Drew