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

how to find no of controls on a windows form .net 2.0

Hi
I have a windows form with 2 textbox ,3 combobox. i want to write a progrma in such a way when i run the form it must give a message box saying " the form has 2 textbox control and 3 combobox control..

What is the logic and solution for this problem..

Hoping for a reply
Bye
May 22 '07 #1
2 915
Plater
7,872 Expert 4TB
Well I guess you could do something like:
Expand|Select|Wrap|Line Numbers
  1. foreach(Control c in Form1.Controls)
  2. {
  3.    string name= c.GetType().Name; 
  4.    //will return things like "Textbox" or "ComboBox"
  5.  
  6.    // Now find some data-collection implementation you like
  7.    // I rather like System.Collections.Specialized.NameValueCollection
  8.    // And either create a new entry with key of [Name] and value 0, 
  9.    // or increment the value already contained in the collection for key [name]
  10. }
  11.  
May 22 '07 #2
I've had problems using the foreach iteration under this circumstance and find the best way to do it is to go:
for (int i=0; i < Form1.Controls.Count ; ++i)
{
//Use the index property for the controls
//Check the type and increment a counter.
}
May 30 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: HJ | last post by:
Hi all, Consider an Access 2002 run-time application on Windows XP. The controls on a form are locked until the user clicks an Edit button. The form is based on a query and all controls are...
3
by: Chris | last post by:
Hi, I'm trying to append text from another class to a generic richTextBox that I've added to a Windows form. I can't seem to figure out how to expose the richTextBox to append text to it. ...
3
by: Poewood | last post by:
Okay here are four classes for a pocket pc program: Input, fpositional, ComboBoxArray and TextBoxArray. The "input" class is the form. I use the fpositional class to handle most of the functions...
10
by: Sacha Korell | last post by:
I'm trying to load a drop-down list with all DropDownList control names from another page. How would I be able to find those DropDownList controls? The FindControl method will only find a...
7
by: Mike Bulava | last post by:
I have created a base form that I plan to use throughout my application let call the form form1. I have Built the project then add another form that inherits from form1, I add a few panel controls...
11
by: VJ | last post by:
I am looking to have 2 Tab Controls on a Windows Forms.. One with Tabs on Top and another with Tabs on the side... I want them both to occupy the entire area of the form, but I need the Tab...
7
by: Andrew McKendrick | last post by:
Hi, I've noticed a bug in VB.NET (latest .NET Framework)... - I have a TabControl on a form with several tabs. - Each tab contains text boxes that are bound to fields in a data source...
6
by: Terry Olsen | last post by:
I decided to use a tab control for my latest project. On Windows XP, the tab control itself is themed (tabs are themed), but the tab pages and any controls I put on them are not themed (except for...
13
by: usenet | last post by:
How and where can one find out about the basics of VB/Access2003 syntax? I am a died in the wool C/C++/Java Linux/Unix programmer and I am finding it difficult to understand the program format...
1
by: Don | last post by:
I'm getting the following exception displayed in the task list at design time for my project: "Code generation for property 'Controls' failed. Error was: 'Object reference not set to an...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.