February 07, 2012   Login   |   Register  
  Search  
  |  
  Home | Blog

The Renegade Blog

Minimize
 Print   

The Renegade Blog

Minimize
 Print   

The Renegade Blog

Minimize
Feb 1

Written by: Renegade
Monday, February 01, 2010 5:46 PM

Check out http://manoli.net/csharpformat/ for a nifty code formatter. I've been using it for years now and really like it. It's got lots of options for most purposes, and should be good enough for anyone with casual requirements. You'd probably want a desktop program if you were doing this a LOT, but really, how much code do you need to format in HTML? Here's a sample of a trick I like to do inside of button click event handlers:

   1:  private void btnRemoveMenuGroup_Click(object sender, EventArgs e)
   2:  {
   3:      ((Button)sender).Enabled = false;
   4:      if (dgvMenus_MenuGroups.SelectedCells.Count > 0)
   5:      {
   6:      string tmpUid = Convert.ToString(dgvMenus_MenuGroups.Rows[dgvMenus_MenuGroups.SelectedCells[0].RowIndex].Cells[1].Value);
   7:      dgvMenus_MenuGroups.Rows.Remove(dgvMenus_MenuGroups.Rows[dgvMenus_MenuGroups.SelectedCells[0].RowIndex]);
   8:      OpenMenuFormat.NodePaths paths = new NodePaths(Application.StartupPath);
   9:   
  10:      bool menu_group_folder_exists = paths.VerifyFolder(paths.Menu_group);
  11:      string menuGroupFile = paths.Menu_group + tmpUid + @".menu_group.xml";
  12:      if (File.Exists(menuGroupFile))
  13:      {
  14:          File.Delete(menuGroupFile);
  15:      }
  16:      }
  17:      ((Button)sender).Enabled = true;
  18:  }

Cheers,

Ryan

Copyright ©2010 Ryan Smyth

Tags:

2 comments so far...

Re: C# Code Formatter

minta kode GDT4,.donk,!!!??

By slamet on   Wednesday, February 02, 2011 7:10 AM

Re: C# Code Formatter

Nope. Not GDT4 code. That's for something else entirely.

By Renegade on   Wednesday, February 02, 2011 7:10 AM

Your name:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment    Cancel  
  

The Renegade Blog

Minimize
 Print   

Tweets

Minimize
 Print   
     
Renegade Minds About | Blog | Contact

  Search

Copyright 2010 by Renegade Minds   |   Privacy Statement   |   Terms of Use
Renegade Minds