473,320 Members | 1,955 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,320 software developers and data experts.

Iterate thru controls collection on a form with groupbox and panels?

Hi,

i'm doing a programe in a few languages so i've found this code that
iterates tru the forms controls and returns there names

but the problem is after re-parenting the controls to optimize the code
i don't get the names of the controls on my groupbox or my panels see
note in get controlname

this is for the .net compact framework so getchild etc is not available

any help would be apreciated

here's the code

//will do translation of form controls
private void TranslateForm()
{
string s;

foreach (Control ctrl in this.Controls)
if ((object)(s = resManager.GetString(GetControlName(ctrl),
currentCulture)) != null)
ctrl.Text = s;
}

//will get control names
private string GetControlName(object sourceControl)
{
FieldInfo[] fi = ((Control)sourceControl).Parent.GetType().GetField s(
BindingFlags.NonPublic | BindingFlags.Instance |
BindingFlags.Public | BindingFlags.IgnoreCase );

foreach (FieldInfo f in fi)
if ( f.GetValue(((Control)sourceControl).Parent).Equals (sourceControl)
) //this line is true only if the control is on the form directly not
if the control is on the groupbox or panel
return f.Name;

return null;
}

Nov 17 '05 #1
0 1485

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

Similar topics

2
by: Simon | last post by:
I've got a webform and many controls on it. I would like to iterate thru the control collection to get all the textboxes control to let me change the text property. Here is my code...for unknown...
2
by: JDavies | last post by:
Hi All I am dynamically Creating DropDownList boxes for a Survey form. These DropdownLists are added to Table Cells programatically. I tried to loop thru the controls on the form but it doesnt...
2
by: Dean Slindee | last post by:
Is there any way to refer to the .text property of a status bar panel thru object syntax, like below (the inner "for" does not work): Public Function FormStatusBarPaint(ByVal frm As Form)...
7
by: Rich | last post by:
Hello, I have a form with 5 textboxes named txt0, txt1, txt2, txt3, tx4. In VB6 I could iterate through these with For i = 0 to 4 debug.print Me.controls("txt" & i).Name Next
8
by: dominique | last post by:
Hi, Is it possible (in vb.net with WinForms) to loop throw controls inside a container (form or panel) sorting the controls on a property (.tabindex for example) ? My problem : on several...
4
by: romy | last post by:
Hi In VB.net I have a set of linkButtons controls in a form , which I want to iterate on them and change their text property. How it's done ? thanks
7
by: RichG | last post by:
I want to lock all controls except the buttons on a form. I sometimes need the form to call lockForms(Me). public sub lockControls(frm as form) for each ctrl as control in frm if...
2
by: RichG | last post by:
With the help of Cor Ligthert in a pryor post I was able to make this sub: Public Sub disableControls(ByVal frm As Form) 'this is to create a read only form that has active buttons Dim x As...
0
by: Rob Meade | last post by:
Hi all, I have a page, where, because it had to all be in one page there are a multitude of panels, with the use of a handful of conditions and the ability to show/hide panels I am able to make...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.