|
I see you fixed your code, which changes things a little bit...
You can always use conditions like so to check if it's null or empty in your constructor regardless of the type (so long as it's a reference type):
if (parameter == null) throw new ArgumentNullException("parameter");
if (parameter.Equals(string.Empty))
throw new ArgumentException("Error", "parameter"); If you want value types to also be valid for your generic class, then you can use something like this in your constructor:
Type t = typeof(T);
if (!t.IsValueType)
{
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thanks, Heath.
the brackets '<' and '>' were missing because I forgot to
check the option 'Don't treat <'s as html-tags' and recognized just later that the brackets were not shown.
|
|
|
|
|
It also helps to put code between <pre></pre> tags, which usually translates the brackets automatically (though not always). This also makes for a nicer fixed-width format (including spaces and tabs you may use) for display code in the forums (and in articles, for that matter).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thanks for that tip.....I guess a good one
|
|
|
|
|
how to load 3d objects in open gl and is it possible to make these models with 3d studio max and import them to opengl(using C#)?
MTSHEDID
|
|
|
|
|
here[^] and here[^]
---------------------------
He who knows that enough is enough will always have enough.
-Lao Tsu
|
|
|
|
|
thank u very much
i couldn't 've started my assignment without it
|
|
|
|
|
hi all,
I have a windows form which is used to create a user in a database. In this form I have several textfields to enter info such as first name, last name, etc...and I have 2 options using radio buttons, one is the classic "male-female" choice and the other is the classic "yes-no" choice. Only I am not able to separate the groups, I have included each pair in a separate groupBox but I don't know what else to do to make them work as 2 separate entities ...for now, only 1 choice over 4 can be selected.
help anyone?
thanks,
Talal
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Make sure that the RadioButton s are actually added to the container's (i.e., GroupBox , Panel , etc.) Controls collection property. If they are added to the same container (i.e., your Form ) but only positioned inside the separate containers, they will act as a single group.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ok, I just made it work, I moved the RadioButtons out of the controlBox and then back in and now it works. I also checked the CS code to make sure they are added to the controls collection as you said, and they are indeed now added, each pair in a difference container
thanks!
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
sorry, I have another question. Is it possible to remove the border of the controlbox? I don't want it to appear, I have tried putting the visible thing to false but then the radiobuttons disappear also. thank you.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
If you don't want the look of the GroupBox , then use a different container like the Panel . Making the change would be easier by just changing the declarations in the source file rather than using the designer and having to cut and paste all your controls again (which un-hook the event handlers but preserve the property values in most cases).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thanks! Panel works great
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
As Heath Stewart said: use another container.
So putting each group of radio buttons on its own panel, instead of group box, should do the trick.
|
|
|
|
|
Hi,
I have setup a simple HttpWebRequest system to use a remote login perl client. Unfortunatly, the perl code sends back multiple responses and when I use the HttpWebResponse.GetResponse() I only get the final response thus missing any cookies or the page I’m redirected too. I have tried looking in the cookies property and the HttpStatusCode property and they act as though no redirection occurred. How do I soluve this problem. I have tried both GET and POST code, and when I type the string in the web browser I get to the page with no problem.
Thanks
|
|
|
|
|
How in the world is your Perl CGI sending back multiple responses?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Well I think I miss phrased that how about multi part responses
Here is a PERL code section
$game= $q->cookie("game",pack ("u","$gamenumber:$username"));
print $q->redirect("nph-remote-client.cgi",-cookie=>$game);
print $q->header(),"\n";
print $q->start_html("test"),"\n";
print "<gamelogin>\n";
foreach (@game){
print "<game id="$_" name="$gamenames{$_}" turn="$turn{$_}" phase="$phase{$_}" side1="$side1{$_}" side2="$side2{$_}" ";
="" if="" ("$gamenames{$_}"="~" m="" demo*="" ){
="" print="" "="">This game is a demo all players can change anything\n";
} else {
print "/>\n";
}
}
Unfortunatly rather then getting that back all I get is the master login page because when you get redirected to the client page and you don't have a cookie you get sent to the master login.
For some reason the HTTP response object isn't detecting the redirect or the cookie.
This is the code: Commented out sections where so I could test both GET and POST
HttpWebRequest Req=(HttpWebRequest)WebRequest.Create("http://lang.hm/SFB/FE/nph-remote-login.cgi?username=JohnP&game=18827");
/*Req.set_Method("POST");
Req.set_ContentLength("username=JohnP&game=18827".length());
Req.set_ContentType("application/x-www-form-urlencoded");
StreamWriter W=new StreamWriter(Req.GetRequestStream());
try
{
W.Write("username=JohnP&game=18827");
}
catch(Exception ex)
{
textBox1.set_Text(ex.getMessage());
}
W.Close();
*/
HttpWebResponse result=(HttpWebResponse)Req.GetResponse();
StreamReader r=new StreamReader(result.GetResponseStream());
textBox1.set_Text(r.ReadToEnd());
r.Close();
result.Close();
|
|
|
|
|
Set HttpWebRequest.AllowAutoRedirect to false , since the default is true . You can then get the cookies, although using a CookieContainer and assigning that to the HttpWebRequest.CookieContainer property should automatically store them even with the redirect. You would then be responsible for manually redirecting to the resource specified in the HTTP response.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'll give it a shot I tried something like that earlier and it didn't work but I will try again, thanks!!
|
|
|
|
|
Dear All,
I am working in VB.NET compact framework for windows CE environment. I have to add a new connection in connection manager programatically. If some one have the solution of this problem, please post some sample code (C# or VB.Net) or useful URL.
Regards,
Muhammad Arif
|
|
|
|
|
I'm afraid there's no simple API for creating connections. Not even for C++ users. There are some third-party libraries which offer the ability to create RAS phone book entries (Connection Manager is based on RAS).
However, I have had luck with saving and restoring registry entries. RAS entries are stored under HKEY_CURRENT_USER\Comm\RasBook. The connection manager settings (which are also required) are under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ConnMgr\Providers\{7C4B7A38-5FF7-4bc1-80F6-5DA7870BB1AA}\Connections.
It is possible to use the RasSetEntryProperties API to create a RAS phone book entry; unfortunately, the device configuration structure (the fifth parameter) is not documented in the Windows CE SDK. For the UNIMODEM telephony provider (used by modem connections) this is a DEVMINICFG structure, which is declared in the Windows CE 3.0 Shared Source[^].
I can't post sample code because I developed this as part of my employment.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
i have 12000 lines of code and lots more to add is this normal and is it normal for it to be slow when i switch between design and code view need reassurance please, new developer
|
|
|
|
|
12,000 lines of code for a tab control? I suggest you look at other implementations here on CodeProject for other ideas. Also, if the designer and editor are running a little slow, this really has nothing to do with C#. I suggest you get a faster computer.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
the tab control has a max of 10 pages each page has textboxes,comboboxes,labels, dtagrids etc with about 50 controls per page so mt 12000 lines includes all the designer generated code as well, as for speed the company has provided me with a laptop 2.4 processor 500mb ram. what do you think my good friend
|
|
|
|
|
Don't know what to tell you. I'm the director of technology and lead architect for a product with almost 400,000 lines of code and about 55 project loaded in my solution at a time with no problems in speed with only a 1.6 Ghz P4 and 512 MB of RAM.
Microsoft MVP, Visual C#
My Articles
|
|
|
|