|
It would be better if you posted the actual code that you try to use. It's hard to tell which errors in the code comes from mistakes typing it in and which errors it is that cause the actual problem.
You can do like this to get access to controls of a specific type:
private void findcontrol(Control.ControlCollection controls) {
foreach (Control ctrl in controls) {
WhateverControlYouWant whatEver = ctrl as WhateverControlYouWant;
if (whatEver != null) {
}
findcontrol(ctrl.Controls);
}
}
Here's a generic version of the method, taking a type and a delegate for whatever to do with the control:
private void ProcessControls<T>(Control.ControlCollection controls, Action<T> action) {
foreach (Control ctrl in controls) {
T t = ctrl as T;
if (t != null) {
action(t);
}
ProcessControls<T>(ctrl.Controls, action);
}
}
Usage example:
ProcessControls<Button>(this, delegate(Button b){ b.Enabled = false; });
Despite everything, the person most likely to be fooling you next is yourself.
modified on Monday, September 1, 2008 12:45 PM
|
|
|
|
|
Thanks a lot.I could understand the first example and i will improve my code.And i will try the second example since i haven`t used such kind of type(ProcessControls<t>).
But what truely trouble me now is the special type i want just could find on the sub-class.In my case,the XXTableAdapter was defind when i added a Dataset in the project.But when i designing the father class i could not used this type.
modified on Monday, September 1, 2008 10:06 PM
|
|
|
|
|
from gmail to aol, without change in any of message data....
|
|
|
|
|
are you trying to do that in a C# program??
if so then id imagine youd have to use gmail's and aol's API's if they even have any...
|
|
|
|
|
If we will use imap.... its possible or not? I gone through RFC3501(IMAP), also overviewed RFC2822(Internet Message format). But i am not getting any clue. I build connection and mail fetch program. but what next for tranfer?
|
|
|
|
|
Hello
Do someone know how to get the device id of a pocket PC?
Best regards
dghdfghdfghdfghdgh
|
|
|
|
|
Please check this link
[^]
Cheers!!
Brij
|
|
|
|
|
how do i deploy it to my pocket
dghdfghdfghdfghdgh
|
|
|
|
|
I want to get a parameter(for example "Path of Data") from user in commandline.
How can I do it?
Hello Friends
|
|
|
|
|
Your Main method accepts a string array as a parameter. This contains what the user (or a shortcut) passed from the command line.
Cheers,
Vıkram.
"if abusing me makes you a credible then i better give u the chance which didnt get in real" - Adnan Siddiqi.
|
|
|
|
|
Please find below:
public static void Main (string[] args)
{
if (args.Length > 0)
{
System.Console.WriteLine (args[0]);
try
{
long number = long.Parse (args[0]);
System.Console.WriteLine ("Number = " + number);
}
catch (System.FormatException e)
{
System.Console.WriteLine ("FormatException" + e);
}
return;
}
System.Console.WriteLine ("Please enter a number");
}
Cheers!!
Brij
|
|
|
|
|
There's this cunning command called GetCommandLineArgs in the Environment class. This should help.
|
|
|
|
|
|
I wonder what exactly you want. But for getting the controls on a page you can have a loop like this
foreach (Controls c in this.Controls)
Ahsan Ullah
Senior Software Engineer
|
|
|
|
|
I have seen some strings formatted like @"Hello World!", or something like that in code i have downloaded on the internet, and i was really wondering what that '@' symbol does. What's the difference between "Hello World!" and @"Hello World!"? Just curious.
void Play() { try { throw Ball(); } catch (Glove) { } finally { Play(); } }
"Failure is only the opportunity to begin again, this time more wisely."
"Don't ask for a light load, but rather ask for a strong back."
|
|
|
|
|
In the case of @"Hello World!" I don't believe it does anything. However
in a directory string
@"C:\Program Files\Common Files"
you don't have to escape the "\" like you would with out it.
"C:\\Program Files\\Common Files"
|
|
|
|
|
|
Ok, thanks. Live and learn.
void Play() { try { throw Ball(); } catch (Glove) { } finally { Play(); } }
"Failure is only the opportunity to begin again, this time more wisely."
"Don't ask for a light load, but rather ask for a strong back."
|
|
|
|
|
I use it a lot when I want large strings, like pieces of xml, to be readable in code.
with @ you can write something like this:
string xml = @"
<xml>
<test>
<value>1</value>
<value>2</value>
</test>
</xml>"
instead of:
string xml = "<xml><test><value>1</value><value>2</value></test></xml>"
Dawn is nature's way of telling you to go to bed.
|
|
|
|
|
Hi,
Can anyone guide me on how to get info on the key(s) pressed?!
TROJAN LIKE LOL
I can disable numbers or chars to being pressed in order to do some validations in c#, but that i can´t do.
Just give me a link if you know something about it
Thanks
nelsonpaixao@yahoo.com.br
|
|
|
|
|
|
i smell a key logger
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
yes yes yes
nelsonpaixao@yahoo.com.br
|
|
|
|
|
This topic is more about the registry then C# itself as i already know how to edit the registry in C#.
I have created a basic webbrowser that i have added some personal features to with the .NET WebBrowser control. I want to be able to set this as my default webbrowser that opens urls when clicked say in an msn convo or when put in the "Run" box.
I am using the following code to edit the registry:
string root = "htmlfile\\shell\\open\\command";
RegistryKey rKey = Registry.ClassesRoot.OpenSubKey(root, true);
rKey.SetValue("", Application.ExecutablePath + " %1");
rKey.Close();
And that works fine, It edits the registry to the path for my browser, and it also does the same in HKEY_CURRENT_USER with the same path.
But yet still when i click a link or run a url in the run box it opens Firefox.
Could someone offer any advice on how to set it to my browser please?
Thanks for your time in reading :]
|
|
|
|
|
I am trying to create a report. I have my main page set up and it is working fine.
I did set it to where you can click a name that is listed and it takes to you a different report passing the name in a parameter. (This works fine).
Now I need it to pull information from a database on the second form that we are on where the name (from the parameter) is equal to in a name column in a database. I see how to do this. This is the error I get:
A data source instance has not been supplied for the datasoure "ID_ITHELPDESKV2_MDFDataSet_UserInfo".
If I run this first in the Report Viewer instead of my main screen it works fine if I manually enter the data in. It is something with going from one report to the other (jumping). I have added that above to the DataSources on that report.
What is going on?
|
|
|
|