Filling a DataGridView with IDfCollection from Documentum

by digvijay 24. May 2010 11:45

Today, I was just writing a quick application to execute a DQL against a Documentum repository and put the results in a DataGridView something similar to Repoint (Repository interrogation utility) does. I thought it would be a nice code snippet to share so here it is:

   1: IDfQuery query = _clientX().getQuery();
   2: query.setDQL(txtDQL.Text);
   3: IDfCollection rowData = query.execute(_session(), 0);
   4: dgvResults.Rows.Clear();
   5: dgvResults.Columns.Clear();
   6:  
   7: bool addedHeader = false;
   8: while (rowData.next())
   9: {
  10:     try
  11:     {
  12:         if (!addedHeader)
  13:         {
  14:             dgvResults.AutoGenerateColumns = false;
  15:             for (int i = 0; i < rowData.getAttrCount(); i++ )
  16:             {
  17:                 string s = rowData.getAttr(i).getName();
  18:                 dgvResults.Columns.Add(s,s);
  19:             }
  20:  
  21:             addedHeader = true;
  22:         }
  23:  
  24:         List<string> items = new List<string>();
  25:         for (int i = 0; i < rowData.getAttrCount(); i++)
  26:         {
  27:             string s = rowData.getString(rowData.getAttr(i).getName());
  28:             items.Add(s);
  29:         }
  30:         dgvResults.Rows.Add(items.ToArray());
  31:     }
  32:     catch
  33:     {
  34:     }
  35: }

DQLExec

Hope that helps someone!

Tags:

Code Snippet

Parsing Enums, the generic way!

by digvijay 12. January 2009 22:30

Here is a little handy generic routine to help parse enumerations. I hope someone finds it useful!

public static T GetEnum<T>(string value) where T : struct
{
if (!typeof(T).IsEnum)
throw new InvalidOperationException("Parameter T must be of type Enum.");
if (string.IsNullOrEmpty(value))
throw new ArgumentNullException("Unable to parse the value.");

return (T)Enum.Parse(typeof(T), value, true);
}

Tags:

.NET | Code Snippet

 

About Digvijay

  Digvijay Chauhan
I am a developer living in Stockholm, Sweden and I love to program and work on cutting edge technologies in the Microsoft Technology space.

LinkedIn Twitter StackOverflow

Certifications

Digvijay Chauhan Microsoft Certification Logo

Other Pages

RecentPosts

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

Most comments

Live Traffic

Live Traffic Feed
  Västra Frölunda, Vastra Gotaland arrived from digvijay.eu on "blank_page"

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

Translate