|
buddy,
try log4net.
******************************
I just want to
know everything
|
|
|
|
|
|
I'm hoping there's a more streamlined approach to this. In a form, I have 7 textboxes and a button. When the button is clicked, each textbox needs to be looked at to ensure it contains something. If the textbox is blank, I have a label on the forum to alert the user of such. Then I direct focus to the blank textbox. So far I've been doing it like this:
if (txt1.text == "")<br />
{<br />
ErrorLabel.text = "Enter something in txt1";<br />
txt1.focus();<br />
}<br />
else if (txt2.text == "")<br />
{<br />
ErrorLabel.text = "Enter something in txt2";<br />
txt2.focus();<br />
}<br />
else if (txt3.text == "")<br />
{<br />
ErrorLabel.text = "Enter something in txt3";<br />
txt3.focus();<br />
}<br />
else if (... and so on, and so on for all 7 textboxes)
Is there a way to do it with less code?
|
|
|
|
|
Realistically you should create a class that implements the data that you want, and then put a binding against the textbox. With a bit of the magic listed here[^] you can save yourself a lot of work keeping validation and items in sync.
|
|
|
|
|
Pete O'Hanlon wrote: With a bit of the magic listed here[^] you can save yourself a lot of work keeping validation and items in sync.
That's a great article. Do you know any similar approach available for web application ?
|
|
|
|
|
You could adapt it using techniques described in this[^] article.
|
|
|
|
|
if you don't want to go with databinding which is a good option, you can combine all the if statements:
if(txt1.Text=="" OR txt2.text=="" OR txt3.text="" OR ...)
{
ErrorLabel.text="All fields must be entered to continue";
}
Their still may be better options though.
Regards,
Thomas Stockwell
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.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Why dont you just use required field validators?
|
|
|
|
|
*Clicks the Back Button2*
"Please fill in all the fields to continue" >
The reason I've stopped using RequiredFieldValidators....
|
|
|
|
|
How about this:
<br />
<br />
foreach (var tb in new TextBox[] { txt1, txt2, txt3, txt4, txt5, txt6, txt7 }) {<br />
if (tb.Text == "") {<br />
ErrorLabel.text = string.format("Enter something in {0}", tb.Name);<br />
tb.Focus();<br />
break;<br />
}<br />
}<br />
<br />
It aint pretty, and I'd prefer data binding, but it'd work?
|
|
|
|
|
If you set required field validators when tabbing to each textbox it instantly does validation i dont see the issue perhaps ive misinterperted your query
A pessimist sees the difficulty in every opportunity; an optimist sees the opportunity in every difficulty I am a Optimist
|
|
|
|
|
That's what I would do too... so it must be wrong somehow.
|
|
|
|
|
I'll give this a shot .. looks interesting
I'd do databinding, but not sure how. I'm still new at this. If I created the DB within Visual Studio I'd be able to do it, but it's created at runtime (SQL CE)
EDIT: I just tried it, and it worked great. Thanks!!!
modified on Friday, April 4, 2008 1:36 PM
|
|
|
|
|
Or set the Button's Enabled property
btn.Enabled = ( txt1.Text.Length > 0 ) && ... ;
|
|
|
|
|
i know this is quite the inapropriate place to ask but i am not getting any answers from the truevision site concerning the 6.5 and it's mousepick train of code. i tried it but the mouse keeps on picking the wall behind the meshes i had set to rotate.
what i am trying to say is i set a wall and three meshes before it to rotate that way if you click on one of the meshes an event will occur but the event keeps on happening to the wall instead. what should i do?
help please
|
|
|
|
|
anarchi23 wrote: what should i do?
sounds like A) you have not bitmasked your picking objects B) you have not cleared your events so they stay on the event stack C) you are unfamiliar with the environment and the confusion runs deeper D) you are unfamiliar with the language and the confusion runs even deeper still.
If you are not getting answers at the truevision forums, the answer may be at the core language, C#. Since I see you recently joined only to cross post, you aren't likely to get many answers, but you might if you phrased it better.
The process you are describing is a 3D problem, but the code that it is uses is obvious a language issue. Not understanding either means you aren't likely to even know which problem is which or where it should be. That is bad news. Brush up on your C# related to the activities being used to narrow this down to a 3D issue not a language use issue. Once you have that down, someone, though there are few of us here, may be able to help. There are very few 3D graphics programmers here and fewer still in C#.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Hello everybody
I have created a table in a data base and I want to use a DataSet to insert in this table while using the TableAdapter.
Normally that this fact grace has the method Insert but that doesn't work. The primary key of the table increments itself automatically.
And when I execute the request to the level of the DataSet that walks very well. You have some ideas.
Thank you for advance
|
|
|
|
|
hi
i have asked this question before as i dint got any answer i am repostingwu it with a clear format
i have a tree view in my form
i want to get the key value of the node
e.node.name returns the key value but it appears under few events
i want to get the key value any where in the form where i need it
please please do reply
Dont Get Paid for the Hours you worked, Get Paid for the Work You Have Done in an Hour.
|
|
|
|
|
simple...
TV.Nodes[XX].Name
XX is index
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
it will return the name not the key value or key string
Dont Get Paid for the Hours you worked, Get Paid for the Work You Have Done in an Hour.
|
|
|
|
|
key??? what do you mean by key
you can use Text property for value...
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
ALT + F4 wrote: hi
i have asked this question before as i dint got any answer i am repostingwu it with a clear format
Well. Aren't you the little liar? You posted this a few posts below and you did get an answer - just because it wasn't exactly right, you shouldn't post porkies here - you will be found out. It's polite to continue on the original thread, and not to cross or multiple post.
|
|
|
|
|
dude i have confessed that i have started a new thread .. in my post...
I wonder most of the mvp's are much bothered about the cross posts and most of them have a single answer for all the questions " What is Google "
SO please do not give unexpected reply's as We all expect answers from U all..
I hope u got it if not leave it ...
Still how to get the key value ?
I have tried in many ways using key value we can get the name
i want to use name and get the key ..
Dont Get Paid for the Hours you worked, Get Paid for the Work You Have Done in an Hour.
|
|
|
|
|
ALT + F4 wrote: dude i have confessed that i have started a new thread .. in my post...
Yes - and you said you had no answers which was a blatant untruth.
ALT + F4 wrote: wonder most of the mvp's are much bothered about the cross posts and most of them have a single answer for all the questions " What is Google "
We are bothered by the multi and cross posts because they make it almost impossible for others to find answers to problems because answers end up spanning multiple threads. This isn't a private email conversation, it's a thread that others may follow to answer issues they have.
The reason we tell people about Google is that it is very obvious that people post questions without doing ANY research for themselves, and that's just lazy.
I reckon that about 90% of the questions asked in these forums could be answered in a couple of minutes by the poster actually getting off their a*se and looking at google for a couple of minutes. It's not hard. It's not rocket science. It's just the type of thing that I do myself before I ask a question.
Do you see me or the other MVPs asking lots of questions on the forums? No? That's because we've mastered the basic technique of looking for information for ourselves; it's not because we know every class in the .NET framework inside out.
ALT + F4 wrote: Still how to get the key value ?
You still haven't explained what your problem actually is. You've thrown a disjointed and rambling thread together that doesn't tell us anything. What key? What name? Do you mean from a dictionary class? If so, take a look at this sample:
public string FindByName<T>(T dictionary, string name)
{
return dictionary[name];
}
|
|
|
|
|
As far as I can tell, a System.Windows.Forms.TreeNode doesn't have a key property.
MSDN[^] for a full listing of Methods and Properties.
Maybe use a dictionary Dictionary<int, TreeNode> TreeNodeDictionary and populate your treeview from this?
Dave
|
|
|
|