|
The question is, why would you want to imperatively set focus on a potentially disabled control?
It's like, are you giving a user a listbox that lists all of the controls on the form and when they select one, you set focus to it? I mean I could see how that's useful...like if you have 20 thousand controls on the form. But here's the real question...Why would you want to make a disabled control enabled?
Maybe it was a handler for a checkbox and when the user checks the box, it enables a previously disabled control and sets the focus so the user...can...oh wait, it disables the control before the user can do anything.
WTF?
|
|
|
|
|
bool bool_report_progress = false;
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
...
if (bool_report_progress)
backgroundWorker1.ReportProgress(x, listbox1_Search.Items.Count + " items were found so far.");
}
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
lable_reported_progress.Text = e.UserState.ToString();
}
private void checkbox1_report_progress_CheckedChanged(object sender, EventArgs e)
{
<font color=#00ee00>bool_report_progress = lbl_reported_progress.Visible = checkbox1_report_progress.Checked;</font>
}
As if I've been charged per letter;P
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
...do it all in Page_Load!
My company recently purchased a smaller company and our development department took over developing their web applications. My first task was to put a new user control on a few pages in one of the apps. While working on the first page I noticed something a bit odd...
(Sorry for the VB. In my defense, I didn't write the app.)
Private Sub Page_Load(blah, blah) Handles Page.OnLoad
' create some objects, initialize some variables
If Page.IsPostBack
' validate the user input
ValidateInput()
' save the user input to the database
SaveInput()
End If
End Sub
Farther down in the code I find this...
Private Sub Submit_Click(obj, args) Handles btnSubmit.OnClick
' direct the user to the new page
Response.Redirect(page.aspx)
End Sub
Smile and the world smiles with you. Laugh and the world thinks your insane.
|
|
|
|
|
I feel your pain there. I'm working on a website right now, and the framework we are using to build it - all its samples, all the pages that are there to build upon - not a single event handler. All postbacks and redirects. Sometimes it makes me want to puke
|
|
|
|
|
And this guy still lives?!!!!
"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." - Rick Cook
"There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib
|
|
|
|
|
disable reader(1)
return
gosub printMainMenu
' disable reader(1)
return
I found this little pretty in a basic program im writing. the indentation indicates my genius.
|
|
|
|
|
bigbrownbeaver wrote: the indentation indicates my genius
The lack thereof indicates otherwise.
|
|
|
|
|
Apparently it was stripped out when I posted it. Double wammy
|
|
|
|
|
tip 1!
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
This one showed up in a code review. 'Nuff said.
string EntityID = new System.Text.StringBuilder("").ToString();
Cheers!
Humble Programmer
,,,^..^,,,
|
|
|
|
|
That is the better substitute for string.Empty
I am fighting against the Universe...
Reference-Rick Cook
|
|
|
|
|
Hey - you told that intern to use StringBuilder , because it is presumed to be faster.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
C# is a mighty tool
Greetings from Germany
|
|
|
|
|
would of been funnier like this
string EntityID += new System.Text.StringBuilder("").ToString();
|
|
|
|
|
Humble Programmer wrote: string EntityID = new System.Text.StringBuilder("").ToString();
string EntityID = new System.Text.StringBuilder("").ToString()<blink>.Replace("", "");</blink>
This should make it faster;P
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
DEATH TO THE BLINK TAG!!!!!
--
If you view money as inherently evil, I view it as my duty to assist in making you more virtuous.
|
|
|
|
|
string EntityID = new System.Text.StringBuilder("").ToString().Replace("", "").Trim();
Just to remove any errant spaces ...
|
|
|
|
|
Good morning
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Ok, I come across stuff like this daily...but this one was the most recent
CREATE PROC foo<br />
<br />
BEGIN TRANSACTION<br />
<br />
SELECT @id = id FROM ...<br />
<br />
IF @id IS NOT NULL<br />
BEGIN<br />
...do some stuff, there is NO ROLLBACK in here or error checking...<br />
COMMIT<br />
END<br />
else<br />
ROLLBACK
It's just so...useless. We only ever rollback if we didn't do anything?
|
|
|
|
|
That makes the ROLLBACK extremely fast.
Chris Meech
I am Canadian. [heard in a local bar]
Stercorum pro cerebro habes. [Cicero]
|
|
|
|
|
Chris Meech wrote: That makes the ROLLBACK extremely fast.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
GibbleCH wrote: It's just so...useless. We only ever rollback if we didn't do anything?
Defensive coding at its finest.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
GibbleCH wrote: It's just so...useless. We only ever rollback if we didn't do anything?
Well, maybe you didn't see a "set XACT_ABORT on" statement buried in the code? If that is set, then rollback is automatic whenever an error occurs.
|
|
|
|
|
Then get rid of the existing ROLLBACK.
|
|
|
|
|
This has a real drawback: you wont see that the code is poor.
Greetings from Germany
|
|
|
|