Connecting Tech Pros Worldwide Help | Site Map

.NET Tips and Tricks

Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,066
#1   Apr 21 '07
Edit
Many times we spend hours and hours trying to solve a problem. When we finally figure it out, we want to share it to keep others from suffering the same way!

That's why we have this "Tips and Tricks" thread. Post your solutions and tricks that you think will help someone down the road here.

If the tip is complex or long, you might want to consider making an article out of it and posting it in the Insights forum.

Looking forward to all the helpful tips!

--insertAlias

Note: The following was the old thread in the answers forum. I am merging it here for convenience.
/Edit

Frinny's Tip O' The Week
Many of us find our way to Bytes.com seeking help while we're facing a programming problem. Sometimes we just need a pointer to get us going in the right direction.

I've started this thread to provide tips and "how-tos" on common problems that everyone faces. Some of these posts will be provided by me (Frinny) but other's will be selected according to how important and informative the posts are.

I hope you'll find something useful here!

---------------------------------------------------------------------------------------------------------------

The 3rd Week of April 2007:
How To Use Databases:
.................................................. .........................................

The 2nd Week of May 2007:
Sessions:
The 3rd Week of May 2007:
Send E-mails: The 4th Week of May 2007:
Faxes:The 5th Week of May 2007:
Checking TextBoxes for a Number:.................................................. .........................................

The 1st Week of August 2007:
The.Net Framework:
The 3rd Week of August 2007:
Reports:
The 4th Week of August 2007:
Connection Pooling:.................................................. .........................................


The 1st Week of September 2007:
Master Pages:

The 3rd Week of September 2007:
GridViews:
.................................................. .........................................

The 4th Week of May 2009:
Asp.NET Life Cycle: .................................................. .........................................

Last edited by Frinavale; May 25 '09 at 09:41 PM. Reason: added reference to asp.net life cycle



sashi's Avatar
Expert
 
Join Date: Jun 2006
Location: Seremban, Malaysia
Posts: 1,630
#2   Jun 27 '07

re: .NET Tips and Tricks


Hi Frinny,

Great work, keep it up. Good luck & Take care.
insertAlias's Avatar
Forum Leader
 
Join Date: Apr 2008
Location: San Antonio, TX (USA)
Posts: 2,603
#3   Dec 12 '08

re: .NET Tips and Tricks


I've moved this thread here and resurrected it so we can start posting our helpful tips and tricks. Anything that you figure out that you think may help someone else is welcome here.

Just add a comment with your tip!

Thanks
--insertAlias
balabaster's Avatar
Moderator
 
Join Date: Mar 2007
Location: Canada
Posts: 757
#4   Dec 12 '08

re: .NET Tips and Tricks


Ben's Tip o' the day:

Always save your work before you go home at night and don't expect that your computer won't have rebooted itself by the time you come into work the next morning!
insertAlias's Avatar
Forum Leader
 
Join Date: Apr 2008
Location: San Antonio, TX (USA)
Posts: 2,603
#5   Jan 11 '09

re: .NET Tips and Tricks


Well, I've recently discovered how to hide the caret (cursor) in a textbox.

Expand|Select|Wrap|Line Numbers
  1. [DllImport("user32")]
  2. private static extern bool HideCaret(IntPtr hWnd);
Then, write an event handler for the "Enter" event for the textbox, and use the handle of the textbox. Like this:
Expand|Select|Wrap|Line Numbers
  1. private void tbOutput_Enter(object sender, EventArgs e)
  2. {
  3.     HideCaret(tbOutput.Handle);
  4. }
Newbie
 
Join Date: Mar 2009
Posts: 1
#6   Mar 26 '09

re: .NET Tips and Tricks


An elegant way to parse Enums in C#: http://ko-sw.blogspot.com/2009/03/el...e-c-enums.html
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,066
#7   Jul 1 '09

re: .NET Tips and Tricks


Conversion Chart for C# to VB scope modifiers:
Expand|Select|Wrap|Line Numbers
  1. -------------------------------------------------------
  2.    C#               |    VB
  3. -------------------------------------------------------
  4. public              |  Public
  5. protected           |  Protected
  6. private             |  Private
  7. internal            |  Friend
  8. internal protected  |  Protected Friend
  9. static              |  Shared
  10. const               |  Const
  11. -------------------------------------------------------
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,066
#8   4 Weeks Ago

re: .NET Tips and Tricks


A website that helps compare/translate VB.NET -> C#:

VB.NET and C# Comparison
Newbie
 
Join Date: Oct 2009
Location: Pune, India
Posts: 6
#9   3 Weeks Ago

re: .NET Tips and Tricks


Vertical progress bar
------------------------------------------------------------
Derive your class as shown below
Expand|Select|Wrap|Line Numbers
  1. class VertProgress : ProgressBar
  2. {
  3.       override CreateParams CreateParams
  4.       {
  5.            get
  6.            {
  7.                  CreateParams crParam = base.CreateParams;
  8.                  crParam.Style |= 0x04;
  9.                  return crParam; 
  10.            }
  11.        }
  12. }
Once you build your application, in the toolbar you will see VertProgress. Drag and drop it in the windows form. Strech it vertically.

Last edited by Frinavale; 3 Weeks Ago at 02:07 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.
Reply


Similar .NET Framework bytes