.NET Tips and Tricks

Collapse
This is a sticky topic.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    .NET Tips and Tricks

    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 Banfa; Jun 1 '11, 09:47 AM. Reason: Updated www.thescripts.com to bytes.com
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    Hi Frinny,

    Great work, keep it up. Good luck & Take care.

    Comment

    • Curtis Rutland
      Recognized Expert Specialist
      • Apr 2008
      • 3264

      #3
      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

      Comment

      • balabaster
        Recognized Expert Contributor
        • Mar 2007
        • 798

        #4
        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!

        Comment

        • Curtis Rutland
          Recognized Expert Specialist
          • Apr 2008
          • 3264

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

          Code:
          [DllImport("user32")]
          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:
          Code:
          private void tbOutput_Enter(object sender, EventArgs e)
          {
              HideCaret(tbOutput.Handle);
          }

          Comment

          • kirillosipov
            New Member
            • Mar 2009
            • 1

            #6
            An elegant way to parse Enums in C#: http://ko-sw.blogspot.com/2009/03/el...e-c-enums.html

            Comment

            • Frinavale
              Recognized Expert Expert
              • Oct 2006
              • 9749

              #7
              Conversion Chart for C# to VB scope modifiers:
              Code:
              -------------------------------------------------------
                 C#               |    VB
              -------------------------------------------------------
              public              |  Public
              protected           |  Protected
              private             |  Private
              internal            |  Friend
              internal protected  |  Protected Friend
              static              |  Shared
              const               |  Const
              -------------------------------------------------------

              Comment

              • Frinavale
                Recognized Expert Expert
                • Oct 2006
                • 9749

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

                VB.NET and C# Comparison

                Comment

                • vkbishnoi
                  New Member
                  • Oct 2009
                  • 6

                  #9
                  How to create a vertical scroll bar in C#

                  Vertical progress bar
                  ------------------------------------------------------------
                  Derive your class as shown below
                  Code:
                  class VertProgress : ProgressBar
                  {
                        override CreateParams CreateParams
                        {
                             get
                             {
                                   CreateParams crParam = base.CreateParams;
                                   crParam.Style |= 0x04;
                                   return crParam; 
                             }
                         }
                  }
                  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; Oct 30 '09, 01:07 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.

                  Comment

                  Working...