Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Desktop Developer

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Your profile

Search

XML Feeds

Google Ads

« Foundations of Programming EbookSolution folders are not being sorted alphabeticaly in Visual studio 2008 »
comments
Rate Post:
submit to reddit Digg!FacebookDotnetkicks

Use the power of linq

Create a form with some controls on it and a textbox called textbox1.

then but this in the load event of the form

  1. textBox1.Clear();
  2.             IEnumerable<Control> query = from p in this.Controls.OfType<Control>() orderby p.TabIndex select p;
  3.             foreach (Control c in query)
  4.             {
  5.                 textBox1.AppendText(c.TabIndex + " " + c.Name + Environment.NewLine);    
  6.             }

and you probably need these usings.

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows.Forms;

At first I couldn’t get it to work until I found this LINQ - Query Windows Forms Controls
by Sam Allen
and then the light came. I was missing the TypeOf method. This is really cool. No more reflection needed to get that control you realy need.

About the Author

User bio imageChristiaan is a forensic technician who programs on the side, although my function description says that I do IT-things for 90% of the time . I'm an avid VB.NET fan and I use lots of the ALT.Net techniques, like unit-testing, nhibernate, logging, IoC, ...
Social SitingsTwitterLinkedInHomePageLTD RSS Feed
3222 views
submit to reddit Digg!FacebookDotnetkicks

Comments and Feedback

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)