Retrieve Class Properties

Get all of the Properties for a Class call Invoices

   Private Function GetInvoiceProperties() as Boolean
         ' List the properties.
         Dim property_value As Object
         Dim properties_info As PropertyInfo() = Invoices(0).[GetType]().GetProperties()

         For i As Integer = 0 To properties_info.Length - 1
            With properties_info(i)
               If .GetIndexParameters().Length = 0 Then
                  property_value = .GetValue(Invoices(RecordNumber - 1), Nothing)
                  If property_value Is Nothing Then
                     ListViewMakeRow(lvwProperties, .Name, "<Nothing>")
                     ListViewMakeRow(lvwProperties, .Name, property_value.ToString)
                  End If
                  ListViewMakeRow(lvwProperties, .Name, "<array>")
               End If
            End With
         Next i
   End Function

   Private Sub ListViewMakeRow(ByVal lvw As ListView, ByVal item_title As String, ByVal ParamArray subitem_titles() As String)
         ' Make the item.
         Dim new_item As ListViewItem = lvw.Items.Add(item_title)

         ' Make the sub-items.
         For i As Integer = subitem_titles.GetLowerBound(0) To subitem_titles.GetUpperBound(0)
         Next i
      Catch ex As Exception

      End Try
   End Sub
Categories: VB.NET Tags: ,

Format DataGridView Cells

Need to format a DataGrid Cell?

   Private Sub grdDataSchema_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles grdDataSchema.CellFormatting
         If e.ColumnIndex = 1 Then
            If (e.Value.ToString.Contains("H")) Then
               e.CellStyle.BackColor = Color.Red
               e.CellStyle.ForeColor = Color.White
            End If
         End If

      Catch ex As Exception
          Throw ex
      End Try
   End Sub

Categories: VB.NET Tags: ,

Convert Office Documents to PDF

December 18, 2010 Leave a comment

Need to convert an Office Document to PDF using the ABCpdf SDK by WebSuperGoo.

Dim theDoc As Doc = New Doc()
Dim xr As XReadOptions = New XReadOptions()
xr.ReadModule = ReadModuleType.XpsAny
theDoc.Read("C:\Office\MySpreadsheet.xls", xr)
Categories: PDF Tags: ,

Query with User Defined Column Selection in EntitySpaces 2010

December 8, 2010 Leave a comment

I need to execute a query based upon a Table Column name that the user will select from a ComboBox and a search value from a Textbox. Since the Column names are strongly typed off of the Enity Collection, I have not stumbled across the method to perform this type of query.

I have figured out how to create a column from the metadata…

Dim esCol As esColumnMetadata =

Then I tried the following…

Job1matchCollection1.Query.Where(esCol.Name = txtSearchField1.Text)

but the SQL query is…


so it appears the the WHERE clause is not getting set. Am I going down the right or wrong path? I am ultimately going to bind the collection to a DataGridView in a WinForm application.sColumnMetadata =


Here’s an example (we are using the literal SQL approach). That is, anything between “” is passed literally straight through to SQL.

string columnName = "EmployeeId";
esColumnMetadata col =;
int id = 1;
EmployeesQuery q = new EmployeesQuery();
q.Where("<" + col.Name + " = " + id.ToString() + ">");
// Just to see the SQL (testing only)
string sql = q.Parse();
EmployeesCollection eColl = new EmployeesCollection();

This generates the following SQL:

SELECT * FROM [Employees] WHERE (EmployeeID = 1)
Categories: EntitySpaces Tags:

Change Color of Control to a System Defined Named Color

November 30, 2010 Leave a comment

myControl.BackColor = Color.FromKnownColor(KnownColor.Control)

Categories: .NET Tags:

Move to Next DataGridView Row via Code

November 21, 2010 6 comments

Dim _rowIndex = grdDataLines.SelectedRows(0).Index + 1
If _rowIndex <= grdDataLines.Rows.Count - 1 Then

Dim nextRow As DataGridViewRow = grdDataLines.Rows(_rowIndex)

' Move the Glyph arrow to the next row
grdDataLines.CurrentCell = nextRow.Cells(0)
grdDataLines.Rows(_rowIndex).Selected = True

End If

Categories: VB.NET Tags: