|
|
|
|
|
|
Get more screen room on your WinForms or WebControls
Get more screen room on your WinForms or WebControls
I've been working on a blotter program for a Police department that needs to enter data about callers, incidents etc. I realized there are two major goals of this application (ok 3 as it needs to work correctly, unlike the solution they use now).
1... Legibility needs to be high 2... A cop doesn't have time to cross their Ts and dot their Is, so they need to be able to enter data as quickly as possibly.
The first goal was easy as I just have to set the laptops to 800x600 and design my forms to like that (but at the same time be friendly to our desktop machines which run 1024x768 or higher). While I was looking at the solution I was replacing and I noticed they have little text labels everywhere and I thought I could save a ton of screen space if I could get rid of the text labels. Then genius struck (although this isn't the first app to do this) and I thought why not just put the text labels inside the textbox control.
This saves a ton of space but totally destroys goal #2 as I can't have the cops clicking the control, deleting it's contents, and filling in data. Or worse yet, having the cops skip over a textbox and letting them submit bogus default data into the database!
So after a little bit of homework I thought up an elegant solution which makes use of the globals concept I mentioned on this site last week. I created a method to clear a textbox control like so
private void clearControl(TextBox myControl, string myDefault) { if (myControl.Text == myDefault) { myControl.Text = ""; } } |
Now I could call my method and send a TextBox and the default value (from my globals file) and I could clear the TextBox. To call this proper you want it to be called when the user clicks on the control and that's with a
private void txtCallerAddress_GotFocus(object sender, System.EventArgs e) { clearControl(txtCallerAddress, ControlDefault.Address); }
|
Which you define with this piece of code...
this.txtCallerAddress.GotFocus += new System.EventHandler(this.txtCallerAddress_GotFocus);
|
And that's it, now when the user clicks on the TextBox control, it checks if the current value is the default, and if so clear it. Then obviously in the piece of code where I apply the DataSet to the database, you want to check if it's the default, and either clear out the value or skip that piece of data being applied (I'm thinking the first choice is a better & easier solution).
|
|
|
|