Zorder of all controls

How do you rearrange the zorder of all controls on a form?
I once knew but forgot.  This is not the same as changing the Tab Order.
Solitaire

Is this useful to you?
Option Strict On
Option Explicit On
Option Infer Off
Public Class Form1
Friend WithEvents Button1 As New Button With {.Parent = Me, .Left = 100, .Top = 100, .Text = "set Z"}
Friend WithEvents tbNewzOrder As New TextBox With {.Parent = Me, .Left = 150, .Top = 130}
Friend WithEvents cboBx As New ComboBox With {.Parent = Me, .Top = 130}
Friend WithEvents Buttons As New List(Of exButton)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim x As Integer = 0
Dim y As Integer = 0
Dim cnt As Integer = 9
For I As Integer = 0 To 9
Dim button As New exButton With {.Parent = Me}
Buttons.Add(button)
x += 10
y += 7
button.Left = x
button.Top = y
button.Text = "exBtn" & I.ToString
cboBx.Items.Add(button.Text)
cnt -= 1
Next
cboBx.Left = tbNewzOrder.Left - cboBx.Width
cboBx.SelectedIndex = 0
tbNewzOrder.Text = Buttons(cboBx.SelectedIndex).zOrder.ToString
End Sub
Sub d(sender As Object, e As EventArgs) Handles Button1.Click
Dim z As Integer = -1
If Integer.TryParse(tbNewzOrder.Text, z) Then
Buttons(cboBx.SelectedIndex).zOrder = z
End If
End Sub
Sub sdaf(sender As Object, e As EventArgs) Handles cboBx.SelectedIndexChanged
tbNewzOrder.Text = Buttons(cboBx.SelectedIndex).zOrder.ToString
End Sub
End Class
Public Class exButton
Inherits Button
Private _zOrder As Integer = 0
Public Property zOrder As Integer
Get
If Me.Parent Is Nothing Then Return _zOrder
Return Me.Parent.Controls.GetChildIndex(Me)
End Get
Set(value As Integer)
_zOrder = value
If Me.Parent Is Nothing Then Exit Property
Me.Parent.Controls.SetChildIndex(Me, value)
End Set
End Property
Public Shadows Property Parent As Control
Get
Return MyBase.Parent
End Get
Set(value As Control)
MyBase.Parent = value
If value Is Nothing Then Exit Property
Me.Parent.Controls.SetChildIndex(Me, zOrder)
End Set
End Property
End Class
“If you want something you've never had, you need to do something you've never done.”
Don't forget to mark
helpful posts and answers
! Answer an interesting question? Write a
new article
about it! My Articles
*This post does not reflect the opinion of Microsoft, or its employees.

Similar Messages

  • Setting the Zorder of ActiveX Controls

    Hi All,
    Is there a way to change the Zorder of ActiveX Controls on a Vi's Front Panel? Some ActiveX Controls do not allow their Zorder to be changed, like the MSFlexGrid Control.
    Thanks,
    Ron

    At the moment, you cannot move to the front or to the back activex containers on the front panel. The only workaround I can think of is to place the containers on a tab control. You will not be able to see both containers at the same time but you get the flexability of changing the order of the containers programatically.
    Jeremy Braden
    National Instruments

  • Get All Control Values [Variant] Method for Global Vars

    Hello,
    to get all the data of controls use in a VI, the methode "Get All Control Values [Variant]" can be used fine.
    Is anything else available for gloabl variables which are use by this VI?
    Thanks.

    Yes, I tried to link this methode to the vi which contains the global vars but got the error message
    "you cannot make a strict vi refernce to a global VIs.
    Any other idea?
    Thanks, Thomas.
    Message Edited by maximint on 05-30-2007 08:41 AM
    Attachments:
    Untitled.vi ‏40 KB

  • Get Specific References for all Controls

    Using slightly modified code from here, I am generating an array of all control references on my main front panel which is then passed through to a number of subVIs. Although this functionality does work, it would be preferable to get specific references to the controls (for example, Boolean RefNum instead of Control RefNum). 
    Getting these specific references seems possible using To More Specific Class and Class Specifier constants. However, data storage becomes an issue because I can no longer use arrays (as they are a different data type). I am not sure if there is another way to pass this data on. I have experimented casting the RefNums to Variants, but to get the data from the variant, I have to know what RefNum type I am expecting which sort of defeats the purpose of doing this in the first place.
    A secondary problem is keeping the names of the references. The Control RefNums do not have names associated with them nor do I know how to assign names to them. I've again tried using variants and using the OpenG Set Data Name function, but this crashes LabVIEW without any indication of why.
    I've attached a version of my code that tries assign names using OpenG Set Data Name and build a variant array. To run it, simple add the VI as a subVI to a VI that has some boolean controls on the Front Panel. Apologies for the rough state of the code - I'm still in the process of figuring out how to make it work so things are a bit messy.
    Solved!
    Go to Solution.
    Attachments:
    Get Specific Control Refs.vi ‏28 KB

    I don't know if you'll get much better.  There is really no way I know of to have some fully flexible way of building named clusters of references based on any given front panel set you feed to it.
    I tend to do things the manual way (as there are also a bunch of references to front panel elements I wouldn't need).  I would do all the bundling work in a subVI.
    I'm attaching a zip file that contains the key VI's (unless I missed something) on the first project where I really tried to abstract out the reference building.  The files are LV9.
    On my main VI, I have the subVI called Build UI References early in the VI during an initialization phase.  I pass the reference to the main VI into that subVI that builds all the references.  I worked it as a master cluster that contains elements that are arrays of references of related controls.  It uses another subVI called Get References and Label Names that I created to help find controls.  I still need to use More Specific Class to get the property references, but I don that only once at the beginning.  I then pass that cluster wire out and to anywhere in my VI that would need access to the references for front panel elements.
    I use arrays of strings to supply the names I need to build and bundle the references.  This lets me ignore controls I don't care about.  The disadvantages to my system is that if I change the name of any control, I need to update the name within this subVI.  And if I want to add any controls, not only do I need to add the label names for the searching functions, I also need to update my typedef cluster (and you definitely want this to be a typedef) to add a spot to store the new reference.
    I hope this gives you some ideas.  It worked for me and I will likely use the scheme on another project (or even rewrite past projects using this scheme.)  If there are any ideas for improvements, I'd be happy to hear them.
    Attachments:
    Build UI refs.zip ‏83 KB

  • Get All Controls References

    Hi all
    If somebody know how can i get all controls references of VI (including controls that founds in Tabs and Clusters). I need generic method, because i haven't information about VI (reference to VI i get only at run-time).
    Thanks, Nadav

    To include the controls on Tabs, pass the array from my previous answer into a for loop, use auto-indexing. Place a Class Specifier Constant in the loop, right click on it and set it's type to a Tab Control. Place a "To More Specific Class" function below the constant, and wire the constant into the top.
    If the control from the array that you pass in is a Tab Control, "To More Specific Class" will NOT return an error. Use a case statement and use the No Error case to expose the Tab Control properties. Return the "Pages" property (an array) and pass this into a for loop. Connect a property node to the indexed pages, then select Controls On Page to return an array of controls ON EACH PAGE. You need to set up a shift register and use build array to return all of the controls from all of the pages. Make sure you close the Page Reference.  You can concatenate the array of Tab Control Page items with your original FP Controls.
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • Change colors of all controls

    Can I programmaticaly to change (to switch between two options) the color of ALL controls by some common command without dealing with property node of each control?
    Thank you,
    Boris

    Pnt,
    Thank you. I tried it as in example with decorations: http://zone.ni.com/devzone/cda/epd/p/id/5217.
    But it looks that this option is not available for controls.
    Attachments:
    decorations.png ‏2 KB
    controls.png ‏7 KB

  • How can I get a reference to all controls on a front panel of one type )for example of the type Text Ring?

    I'd like to set the strings[] property of all the Text Ring controls on a front panel at once without creating a property node for every text ring. How can i do that?

    > How can I get a reference to all controls on a front panel of one type
    > )for example of the type Text Ring?
    >
    > I'd like to set the strings[] property of all the Text Ring controls
    > on a front panel at once without creating a property node for every
    > text ring. How can i do that?
    This is likely more complicated than making property nodes for each
    ring, but you can do it. Make a subVI that takes in a panel reference,
    reads the array of control references, loops through them looking for
    rings, and modifying the Strings[] property on each ring.
    The part of this that will probably be the least obvious, when you
    have an array of control references there are two ways to find out
    if an element is a ring. You can read the classID and compare it
    to the cla
    ssID of a true ring control. An alternative is to cast
    the control reference to a ring control using a Cast to more specific
    node and wire the error out to a case structure. The error case is
    where the objects that aren't rings will go. The success case case
    where you will have a valid ring refnum that you can use to modify
    the strings.
    Greg McKaskle

  • Loop through all controls in view

    Hi Everyone,
    I need to cycle through all the controls on a view.
    I have set each of the controls of type UISegmentedControl with a unique tag number.
    I am using this tag number to perform a lookup in database for the value of the segmented control.
    So, my question is this.... how do i cycle through all the controls on a view?
    thank you
    take care
    tony

    alt-088 wrote:
    I think we are close - just one correction.
    The segmented controls are all at design time, there will be no new controls added.
    I'm not clear on what's been corrected. The sample code I gave you assumed all the controls were known at compile time. So I think the example code addressed the problem you're trying to solve. The last paragraph of that post was just an afterthought, to explain what to do in case you ever needed to add controls dynamically.
    -> loop through all controls on view
    -> if control is of type uisegmentdcontrol
    then do database lookup on tag
    Set segment value to value returned from database
    Once again, if I correctly understand the above, the code I gave you does exactly what you want. You haven't indicated you want to take any action when a control is not a segmented control, so I don't see why you'd want to include them in the loop. However, if you actually do need to enumerate non-segmented controls (or other subviews), my last response advised you to set the tag properties of all those other controls, making sure the range of those tags is different from the range of the seg control tags.
    The part that eludes me is the looping through all the controls on the view
    I guess the part that eludes me is why you're so interested in enumerating all the controls, when you only seem to be interested in the segmented controls. But even if you really do need to look at every control, I don't see why you're rejecting the solution I gave you. [viewWithTag:|http://developer.apple.com/iphone/library/documentation/UIKit/Ref erence/UIViewClass/UIView/UIView.html#//appleref/doc/uid/TP40006816-CH3-SW26] is a powerful method which recursively walks the entire view hierarchy to find whatever tag it's looking for. If you use it correctly (e.g. by assigning unique tag numbers that tell you what type of control you've found), it will save you lots of trouble.
    If, for some reason, you insist on doing this job without using viewWithTag, the next best might be something like this:
    - (void)doSomethingWithEachSegCtrlInView:(UIView *theView) {
    UIView *subView;
    for (subView in theView.subviews) {
    if ([subView respondsToSelector:@selector(selectedSegmentIndex)]) {
    // subView is a segmented control ...
    else {
    // subView is not a segmented control ...
    if ([subView.subviews count]) {
    // this subview has its own subviews
    [self doSomethingWithEachSegCtrlInView:subView];
    Note that the above is a more difficult, more error prone method than the sample in my first response. Firstly, it needs to recurse in case any controls are placed on subviews of the main view (or on subviews of those subviews, etc.), a capability already built into viewWithTag. Secondly it needs to identify the type of each subview object. [respondsToSelector:|http://developer.apple.com/iphone/library/documentation/Co coa/Reference/Foundation/Protocols/NSObjectProtocol/Reference/NSObject.html#//appleref/occ/intfm/NSObject/respondsToSelector:] is the preferred way of identifying the class of an object, especially when the selector argument represents one of the methods you intend to use. However there's no reason to get into the business of identifying the class of an object, when you could have given that object a unique tag number in the xib, where there was no question about its class.
    Hope the above communicates the solution better than my first response!
    - Ray

  • How can I make a global change so all controls and indicators labels on the front panel change to another colour?

    How can I make a global change so all controls and indicators labels on the front panel change to another colour?
    I need to change the front panel so that it can be used in a dark environment.

    Hi
    The only way I see, is to use the "Controls[]" property and iterate through all of them. But don't forget about nested elements (i.e. clusters, tab-controls, ...).
    Thomas
    Using LV8.0
    Don't be afraid to rate a good answer...

  • Make all controls inside a Groupbox or Panel unusable without disabling them

    Hello !
    I'm using Vb.net 2013 , NET 4.0.
    I'm trying to make all the controls inside a Groupbox ( or Panel) , unusable by users if a condition is true.
    This is the code that I'm using :
    Class NW
    Inherits NativeWindow
    Public Sub New(hwnd As IntPtr)
    AssignHandle(hwnd)
    End Sub
    Const WM_NCHITTEST As Integer = &H84
    Protected Overrides Sub WndProc(ByRef m As Message)
    If m.Msg = WM_NCHITTEST Then
    Return
    End If
    MyBase.WndProc(m)
    End Sub
    End Class
    Dim nwss As List(Of NW) = Nothing
    Public Sub block_area(flag As Boolean)
    If flag = True AndAlso IsNothing(nwss) Then
    nwss = New List(Of NW)()
    For Each c As Control In GroupBox1.Controls
    nwss.Add(New NW(c.Handle))
    Next
    Else
    If flag = False And (Not IsNothing(nwss)) Then
    For Each nw As Object In nwss
    nw.ReleaseHandle()
    Next
    nwss = Nothing
    End If
    End If
    End Sub
    The problem is that this code works for all controls , except the TextBox and DateTimePicker . These 2 controls remain always clickable and editable so usable by users.
     What can I do ?
    Thank you !

    Ok , friend , if you don't like this question , you can close it anytime. Next time when I need to make a question , I will be careful to do more hard questions like : " What will be the final result of a=1  a=a+1" . This is pure VB.net ,
    I think.
    I'm sorry if it upsets you that your code will not work as intended. Everyone here is just trying to help you understand that there is no good solution to your problem from a managed code perspective in Windows Forms. The best answers are to use a different
    presentation system or to spin your own custom control at the Win32 level (or buy one from someone else who has already done all of that work). The next bester answer is to fudge it with an image that you capture and update as appropriate.
    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
    ok , can you only give me a simple answer : What is the WM code that has to do with pressing keys from keyboards in a control ? I try to modify my code if you help me with this. Thank you !
    Hello Friend Here is my sample - very elementary, please make more good:
    Public Class clsControl
    Inherits Control
    Public actualControl As Control
    Private Property hiddenLock As Boolean = False
    Public Property lock As Boolean
    Get
    Return hiddenLock
    End Get
    Set(value As Boolean)
    If value Then
    Dim _bmp As New Bitmap(actualControl.Width, actualControl.Height)
    actualControl.DrawToBitmap(_bmp, actualControl.ClientRectangle)
    actualControl.Enabled = False
    actualControl.Visible = False Me.BackgroundImage = _bmp
    Me.Controls.Remove(actualControl)
    Else
    actualControl.Enabled = True
    actualControl.Visible = True
    Me.Controls.Add(actualControl)
    Me.BackgroundImage = Nothing
    End If
    hiddenLock = value
    End Set
    End Property
    Public Sub New(ByRef _control As Control)
    actualControl = _control
    Me.Controls.Add(actualControl)
    actualControl.Location = New Point(0, 0)
    actualControl.Visible = True
    End Sub
    End Class
    'FORM1 CODE
    Private _c As clsControl
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim _txt As New TextBox
    _txt.Size = New Size(100, 20)
    _txt.Visible = True
    _c = New clsControl(CType(_txt, Control))
    Me.Controls.Add(_c)
    _c.Size = _txt.Size
    _c.Visible = True
    End Sub
    Private Sub Form1_Click(sender As Object, e As EventArgs) Handles Me.Click
    _c.lock = Not _c.lock
    End Sub
    Enjoy friend I spent time to make it work.

  • After ios6 update, I have lost all control of audio via Bluetooth, plus my Bluetooth car radio is no longer displaying track information from the iPhone. Help!

    After ios6 update, I have lost all control of audio via Bluetooth, plus my Bluetooth car radio is no longer displaying track information from the iPhone. Help!

    Hi there,
    You're running an old version of Safari. Before troubleshooting, try updating it to the latest version: 6.0. You can do this by clicking the Apple logo in the top left, then clicking Software update.
    You can also update to the latest version of OS X, 10.8 Mountain Lion, from the Mac App Store for $19.99, which will automatically install Safari 6 as well, but this isn't essential, only reccomended.
    Thanks, let me know if the update helps,
    Nathan

  • My iPod nano screen is frozen and will not respond. It shows the song which was playing is paused, but will not resume playing. I have held down all controls, and changed the slide switch, but nothing happens

    my iPod nano screen is frozen and will not respond. It shows the song which was playing is paused, but will not resume playing. I have held down all controls, and changed the slide switch, but nothing happens

    Hi Goofy Goat,
    Welcome to the Apple Support Communities!
    It sounds like you have done some great troubleshooting for your iPod nano that is not responding. In this situation, if resetting it did not resolve, I would suggest restoring the iPod back to its factory settings and then sync your content back onto it from iTunes. Please use the following article as a resource for restoring.
    Restoring iPod to factory settings
    http://support.apple.com/kb/HT1339
    Have a great day,
    Joe

  • How to make appear all controls?

    in examples, some controls appears
    how to make these control appear in a new project?
    i'm looking for data i/o controls
    thanks

    Not sure what the problem is...if you see a control in one of the examples that you want in another VI just copy and paste. If you want to make a front panel template just create a VI template (option in the new...dialog) and paste and arrange the controls on the front panel of that...
    If there is code in the example that hides the control and you wonder how to make it appear again just go to the diagram, locate the terminal of the control, right-click on it and select show...
    If the problem is how to make all controls on a panel appear (if e.g. there are 100 controls hidden and you want to un-hide them all)...open a reference to the front panel of the VI, get a reference to all the controls using the get control refs property and then wire the array of references
    to an auto-indexed for-loop where you wire the references to a "visible" property and set the property to true...run it and all the controls will reappear.
    MTO

  • "All Controls" Keyboard Preferences Keeps Turning Off

    Every so often the keyboard access setting on my computer switches from "All Controls" (my preferred option) to "Text boxes and lists only."
    It doesn't seem to match up with any specific event: logging out, rebooting, shutting down, etc. Just every once in a while it'll change back. Sometimes it'll last two weeks, sometimes it'll just last two hours before it goes back to "Text boxes and lists only."
    Anyone else experienced this?
    Anyone know how to fix it?

    I actually never goes back to the way I want it.
    The default option for Full keyboard access is "Text boxes and lists only." I prefer "All controls."
    The default option for the dock is to always have it visible. I prefer auto-hide.
    So, it'll frequently flip back to the default option, but never switch to the way I prefer it.
    Toggling the setting back to how I want it does fix the problem... it's just one of those things that shouldn't happen.

  • Set default for all controls

    How do I set a default for all controls?
    For example, I want the label to always appear on the left.  Instead of setting the control attribute for each LED separately, I'd rather set a default to be applied to all LEDs.
    I'd prefer to do this programmatically.
    Thanks!!!

    Hi,
    one possibility is to use the function call SetAttributeForCtrls from the programmer's toolbox library.
    Another, to generate the controls programmatically - if you are using your own functions to do so you can define the default as to your liking.
    Wolfgang

Maybe you are looking for

  • Is there a plug in to make my 2007 macbook pro able to install Mountain Lion

    Is there a plug or something in to make my 2007 macbook pro able to install Mountain Lion? I bought it in early 2007 so just miss out on the cut off point. Is compatibilty based on Hardware or software? Thanks Mark

  • Can Enery Saver settings affect performance in iDVD

    Hi, I would like to know if changing the settings in Energy Saver in System Preferences will result in iDVD encoding taking MORE time and thus save on processor heat etc, thus allowing me to fully encode a slideshow and its transitions without the iD

  • Oracle 10g database as Resource manager and heuristic transaction decision

    Hi, I have read in documents about distributed tarnsaction that resource manager like oracle databasecthat are involved in distributed transaction can take heuristic decision(unilateral decision) and can either rollback or commit the transaction asso

  • Installing java 2 sdk in RedHat linux7.1

    I have downloaded java2 sdk (rpm file) and installed it in RedHat linux 7.1 but I can't run javac to compile my java programs. can somebody please explain why???

  • Adobe 9.5.1 crashing

    When trying to print downloaded pdfs off the internet Adobe is crashing when I send the document to print to a HP Laserjet P2015 printer. I've tried different documents and its happening with all of them. The documents print fine when I use my Epson