473,402 Members | 2,046 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,402 software developers and data experts.

Determine order of controls on form

Hi!

Is there a way to determine the (tab-)order of controls at runtime? My goal
is to get a unique number for each control on a form that could deal as a
priority value for that control.

The easiest approach is the TabIndex-property of all controls, but
unfortunately this does not work with several levels that exist when some
controls are placed on a panel.

I need a common approach to this problem because I don't know how the forms
will look like on whom that algorithm is run.

How can I get a real Z-order value that is unique for the whole form and not
just for the level?

TIA,

Markus
Nov 17 '05 #1
1 2529
The code below will traverse controls, starting at the beginning (Form), and
assign a simple priority based on the actual tab order. These priorities are
stored in a hashtable using the control as the key.

private Hashtable priorities = new Hashtable();

/// <summary>
/// Get the controls on the form and assign a
/// priority based on the tab order.
/// </summary>
private void GetPriorities()
{
Control ctrl = this;
int priority = 0;
priorities.Clear();
while ((ctrl = this.GetNextControl(ctrl, true)) != null)
{
priority++;
this.priorities.Add(ctrl, priority);
}
}

Now if you wanted to get the priority for a given control...

object val = this.priorities[this.button1];
if (val is int)
{
// MessageBox.Show(val.ToString());
}

--
Tim Wilson
..Net Compact Framework MVP

"Markus Wildgruber" <ms********@syska.de> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi!

Is there a way to determine the (tab-)order of controls at runtime? My goal is to get a unique number for each control on a form that could deal as a
priority value for that control.

The easiest approach is the TabIndex-property of all controls, but
unfortunately this does not work with several levels that exist when some
controls are placed on a panel.

I need a common approach to this problem because I don't know how the forms will look like on whom that algorithm is run.

How can I get a real Z-order value that is unique for the whole form and not just for the level?

TIA,

Markus

Nov 17 '05 #2

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

Similar topics

18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
2
by: CJack | last post by:
hi, i have a window form with different controls. i want to loop through all the controls and write the types and lables of each control in a file. I dnt know how to determine the type of a control...
9
by: Bob Cummings | last post by:
Greetings I have googled this to no avail, maybe someone here can help. I have a user control that has several radio buttons and text boxes. I place 5 of these user controls on a windows form....
1
by: MuZZy | last post by:
Hi, I need to build a function which would return all controls which are upper in z-order relatively to given control. I need this in order to be able to temporary bring the control to front...
1
by: Robert Boudra | last post by:
In vb.net, if I instert a new control onto a form and I want that control to occur in the middle of the Tab Order, how can I insert it into the tab order and automatically increment the tabindex...
7
by: Doru Roman | last post by:
Hi, What is the fastest way to evaluate manually the result in this case: int a, b, c; a = 255; b = 122; c = a & b; The only way I know is transforming each number into the binary value...
7
by: CDMAPoster | last post by:
I have a form in A97 that requires many textboxes and comboboxes (about 300). The customer insists on seeing all the information on one form so I can't break it up into several forms. Neither...
4
by: Bill Fuller | last post by:
I am trying to determine the type for ActiveControls using 3rd party controls (Infragistics in this case) during runtime and getting a rather odd return type at runtime for the UltraWinEditor. ...
8
by: Michael R | last post by:
Hi everyone. I have a few subforms in the main form that are dependent on each other with their data (not with child/master fields). Sometimes I get an invalid reference error because the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.