Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
700
Sorting tools in a popup menu.
posted

Hello,

I have a context menu with a popup menu on it.  At runtime we programmatically add items to the popup menu.  The items are retrieved from the database in the order we want them to display from newest to oldest.  We loop through them and add items based on them to the popup menu.  I've even set a defaultview sort on the datatable the rows live in.  Instead of coming out

3
2
1

the menu is populated with

2,
3,
1

Unless ... I put a breakpoint on the code where we add the items.  In which case it _sometimes_ behaves the way I want it to.  There is no alternate code path and the datatable is filled with the same, presorted data every time.

Here's the code.  The only change is the name of the tables/columns

Dim dtTmp As DataTable = modDBA.GetDataTable_Generic("SELECT IDColumn FROM tableName WHERE DeleteFlag=0 AND ParentIdColumn=" & Me.ParentId & " ORDER BY IDColumn Desc")

Dim CurrentId As Integer

dtTmp.DefaultView.Sort = "IDColumn DESC"For x As Integer = 0 To dtTmp.Rows.Count - 1

CurrentId = dtTmp.Rows(x)("IDColumn")

If Not Me.utmContextMenu.Tools.Exists("T" & CurrentId .ToString) Then

Dim miItem As New Infragistics.Win.UltraWinToolbars.ButtonTool("T" & CurrentId .ToString)
Me.utmContextMenu.Tools.Add(miItem)

End If

Next

 

Any ideas?  Oh yeah, version is 5.3