yes, we are still using visual studio 2005 for our development, although we hope to cut over to 2010 in the next few weeks. anyways, a customer was having problems printing reports to a particular printer, and from previous research i knew the problem was turning the “No Printer” option on in the crystal reports designer. now we have a lot of reports, so i wanted to automate this process for all our reports. so i turned to the built-in scripting functions of visual studio, however, it turns out that you can’t control dialogs through macros. so one person recommended using autohotkey, and i had a basic knowledge of that, so I would give it a try.

Continue reading

after much searching and reading many blogs and forums, i never found a comprehensive answer on the best way to get the index of a datarow from the currencymanager in vb.net. i found a few posts that led me in the right direction, not none that did exactly what i wanted. so this is what i came up with, i’m not sure if it’s the most efficient, but it seems to work.

1
2
3
4
5
6
7
8
9
10
11
12
13
' RowToFind is the DataRow we are looking for the index of
Dim cm As CurrencyManager = Me.BindingContext.Item(dataSource, dataMember)
Dim dv As DataView = DirectCast(cm.List, DataView)
Dim idx as Integer = -1
 
For i As Integer = 0 To dv.Count - 1
    If dv.Item(i).Row Is RowToFind Then
        idx = i
        Exit For
    End If
Next 
 
cm.Position = idx
' RowToFind is the DataRow we are looking for the index of
Dim cm As CurrencyManager = Me.BindingContext.Item(dataSource, dataMember)
Dim dv As DataView = DirectCast(cm.List, DataView)
Dim idx as Integer = -1

For i As Integer = 0 To dv.Count - 1
    If dv.Item(i).Row Is RowToFind Then
        idx = i
        Exit For
    End If
Next 

cm.Position = idx

our problem with the previous method, was that when you deleted a row, it would return the wrong index. this appears to bypass that problem.