473,800 Members | 2,541 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I use Reflection to do this?

I have a situation where I want to autotab to the next control when the
previous control is defnitively completed with data. The dataentry controls
are arranged in a grid and are named, for example:

txtPC1 txtInstallAmt1
txtPC2 txtInstallAmt2
txtPC3 txtInstallAmt3
txtPC4 txtInstallAmt4

All change events for a column are mapped to a single method appropriate for
that column.

If Pay Code (PC) contols accept 0/1 as valid, it is processesed as follows:

private void txtCPC_TextChan ged(object sender, System.EventArg s e)
{
if (name.Substring (0, name.Length - 1) == "txtPC")
{
string row = name.Substring( name.Length - 1, 1);
switch (this.ActiveCon trol.Text)
{
case "0":
case "1":
switch (row)
{
case "1":
txtCInstallAmt1 .Focus();
txtCInstallAmt1 .SelectAll();
break;
case "2":
txtCInstallAmt2 .Focus();
txtCInstallAmt2 .SelectAll();
break;
case "3":
txtCInstallAmt3 .Focus();
txtCInstallAmt3 .SelectAll();
break;
case "4":
txtCInstallAmt4 .Focus();
txtCInstallAmt4 .SelectAll();
break;
}
break:
}
}
}

I know the following change to the above is invalid syntax but I offer it as
an example of something I would like to do at runtime rather than compile
time:

string row = name.Substring( name.Length - 1, 1);

switch (this.ActiveCon trol.Text)
{
case "0":
case "1":
"txtCInstallAmt " + row + ".Focus()";
"txtCInstallAmt " + row + ".SelectAll ()";
break;
}

Does anyone know the best way to do this?

Nov 16 '05 #1
3 1115
Bill <nf*@nospam.com > wrote:
I have a situation where I want to autotab to the next control when the
previous control is defnitively completed with data. The dataentry controls
are arranged in a grid and are named, for example:

txtPC1 txtInstallAmt1
txtPC2 txtInstallAmt2
txtPC3 txtInstallAmt3
txtPC4 txtInstallAmt4


Rather than use reflection, why not just create an array with the
appropriate entries in, or a map from each control to the next?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
"Bill" <nf*@nospam.com > wrote:
I have a situation where I want to autotab to the
next control [...]


Form.ProcessTab Key method?

P.
Nov 16 '05 #3
"Paul E Collins" <fi************ ******@CL4.org> wrote in message
news:ce******** **@sparta.btint ernet.com...
"Bill" <nf*@nospam.com > wrote:
I have a situation where I want to autotab to the
next control [...]


Form.ProcessTab Key method?


Encouraging, but unfortunately it didn't work.
Nov 16 '05 #4

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

Similar topics

0
1383
by: A. Wiebenga | last post by:
Hi all! I am a student at the Hogeschool van Arnhem en Nijmegen in Holland. I am currently involved in a research project regarding Reflection. Purpose of the research project is to document what Reflection is (I can answer this question myself), what kind of Reflection Techniques there are (.NET Reflection, Python Reflection etc. I can answer this one myself too). The main question I need to answer is related to the implementation of...
10
7374
by: Sunny | last post by:
Hi, I have an old problem which I couldn't solve so far. Now I have found a post in that group that gave me an idea, but I can not fully understand it. The problem is: I'm trying to use a Windows.Forms.UserControl in a COM environment, i.e. I want to host that control in a COM host. So far, so good, I can host it, but I can not reach the parent COM object from the control (Parent property is null :( ). I have stopped the control in the...
0
1548
by: Shawn Hogan | last post by:
Hi everyone, I've been trying to execute a control's private event code via reflection from another class with the goal of potentially doing some unit testing. The examples below are trying to execute button2's click event. This works great when i know the name of the method that i want to invoke. I do so by doing this: Dim AssemblyPointer As Reflection.Assembly
5
1864
by: heddy | last post by:
I understand that reflection allows me to discover the metadata of a class at runtime (properties, methods etc). What I don't understand is where this is useful. For example: If I am the sole author of an application, I already know the metadata about my classes - I wrote them. And even if I did not - Let's say I buy a 3rd party class lib, it will be documented for me with that lib. If I am part of a dev team, the same is true - If...
5
1404
by: DesCF | last post by:
What exactly is Reflection ? I've looked at the definition in Help but I don't find it very helpful! I just stare at it blankly and can't quite seem to grasp its meaning conceptually. Reflection implies something reflected. Does anyone have a good cogent description of its meaning ? Des
9
3849
by: Kuberan Naganathan | last post by:
Hello all Does anyone know of a good way to use reflection in c++? I don't mean simply using rtti or dynamic casting. I'm talking about java/c# style reflection where an actual instance of an object can be constructed through reflection and method calls can be made via the reflection apis.
17
2314
by: raylopez99 | last post by:
What good is C# Reflection, other than to find out what types are in an assembly? And to dynamically invoke methods in an assembly (.dll or .exe)? Also, bonus question, can you use Reflection to build a compiler? One that will construct a user defined class "on the fly" (literally, the user defines a class, instantiates it, and runs it from the console mode, all the while prompted by the program)? I guess so, but my final question...
0
1703
by: Gustavo Arriola | last post by:
Hola a todos! Estoy intentando ejecutar un método usando Reflection. El código es el siguiente: public static void SoapHandler(Exception Error) { try { Type assemblyType;
6
1971
by: Cralis | last post by:
Hi guys, Someone once said, 'You can do that with reflection'. I can't recall what it was I was trying to do at the time, but then he said, 'Any developer knows what reflection is...'. I kept quiet and smiled. What is reflection!? I have been reading it up, and all I can work out is that it has something to do with Late Binding, and the use of GetType and Type.
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10274
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10033
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7576
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.