About      |       Articles      |      Services      |      Software      |      Contact

Latest Free SharePoint Software

ARB Security Solutions regularly releases free SharePoint software, including WebParts, Client Applications, Framework Extensions, and other Miscellaneous Components.
The most recent freeware is:

Title: Simple SharePoint Rollup WebPart
Date Published: 10/22/2009

Previous Two Free WebPart Releases:

SecureCenter For SharePoint

By SharePoint security integrators, for SharePoint security integrators.

SharePoint Security Assurance Program™

For externally facing SharePoint deployments, security is an acutely important deployment concern. Learn how through daily security scanning, you can ensure external business users and partners that they can collaborate in confidence!

Security Assurance WebPart:



Why CommaDelimitedStringCollection Made Me Happy Today

Another thing that I stumbled on today that has made me all sorts of happy is the CommaDelimitedStringCollection class, which basically let's you take a bunch of string values and work with them in a comma delimited format (so I guess the class name is pretty intuitive :) ). I can't even explain how many times I have re-invented this wheel. So let's say that you have a ListBox control that contains a set of string type values, and you are adding the selected values to a list generic in something like an event handler, you would have this basically:

C#:
  1. List<String> m_gBoxGeneric = new List<String>();
  2. foreach (string l_strValue in l_oTbExample.SelectedItems)
  3. {
  4. m_gBoxGeneric.Add(l_strValue);
  5. }

where the l_oTbExample is just a ListBox control. This isn't very earthshattering and I am just using that loop as an example. Now, let's say you want to output those selected values into a comma delimited format. The easiest way to do it is to just use the CommaDelimitedStringCollection class, which natively provides this functionality. It would look like this:

C#:
  1. CommaDelimitedStringCollection m_oDelimitedFormat = new CommaDelimitedStringCollection();
  2.  
  3. List<String>.Enumerator l_oEnumerator = m_gBoxGeneric.GetEnumerator();
  4. try
  5. {
  6. while (l_oEnumerator.MoveNext())
  7. {
  8. string l_strBoxVal = l_oEnumerator.Current;
  9. m_oDelimitedFormat .Add(l_strBoxVal);
  10. }
  11. }
  12. finally
  13. {
  14. l_oEnumerator.Dispose();
  15. }

Then you can just output the comma delimited values by doing a m_oDelimitedFormat.ToString() and you are done!

  • Share/Bookmark

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment