Hello,
The actions pane locks up after selecting a listbox.
I have tried all kinds of things and have narrowed it down to this. If
I click in the listbox the action pane locks up. Neither a combo box
nor a button will work after clicking in the list box. There are no
events associated with the list box. This is a mystery to me.
What could be causing this behavior? What could be the remedy?
Here is the Action Pane code
\\\
Public Class ActionsControl
Private Sub ActionsControl_ Load(ByVal sender As Object, ByVal e As
System.EventArg s) _
Handles Me.Load
Me.SuppliersTab leAdapter.Fill( Me.NorthwindDat aSet.Suppliers)
Me.ProductsTabl eAdapter.Fill(M e.NorthwindData Set.Products)
End Sub
Shared Sub SetHeadings(ByV al tblCell As Word.Cell, ByVal text As
String)
'The first time the table is made
With tblCell.Range
.Text = text
.Font.Bold = True
.ParagraphForma t.Alignment =
Word.WdParagrap hAlignment.wdAl ignParagraphCen ter
End With
End Sub
Private Sub AddData(ByVal row As DataRow, ByVal companyName As
String)
' Create a table if it doesn't already exist.
If Globals.ThisDoc ument.Tables.Co unt = 0 Then
Try
' Create a table.
Dim tbl As Word.Table =
Globals.ThisDoc ument.Tables.Ad d( _
Globals.ThisDoc ument.Applicati on.Selection.Ra nge,
1, 4)
' Insert headings.
SetHeadings(tbl .Cell(1, 1), "Company Name")
SetHeadings(tbl .Cell(1, 2), "Product Name")
SetHeadings(tbl .Cell(1, 3), "Quantity")
SetHeadings(tbl .Cell(1, 4), "Unit Price")
Catch ex As Exception
MessageBox.Show ("Problem creating Products table: " &
ex.Message, _
"Actions Pane", MessageBoxButto ns.OK,
MessageBoxIcon. Error)
End Try
End If
' Add data from data row to the table.
Dim selection As Word.Selection =
Globals.ThisDoc ument.Applicati on.Selection
If selection.Table s.Count > 0 Then
Dim newRow As Word.Row =
Globals.ThisDoc ument.Tables(1) .Rows.Add()
With newRow
.Range.Font.Bol d = False
.Range.Paragrap hFormat.Alignme nt =
Word.WdParagrap hAlignment.wdAl ignParagraphLef t
.Cells(4).Range .ParagraphForma t.Alignment =
Word.WdParagrap hAlignment.wdAl ignParagraphRig ht
.Cells(1).Range .Text = companyName
.Cells(2).Range .Text = row.Item("Produ ctName").ToStri ng
.Cells(3).Range .Text =
row.Item("Quant ityPerUnit").To String
.Cells(4).Range .Text =
Math.Round(row. Item("UnitPrice "), 2)
End With
Else
MessageBox.Show ("Cursor must be within a table.", _
"Actions Pane", MessageBoxButto ns.OK,
MessageBoxIcon. Error)
End If
End Sub
Private Sub Insert_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles Insert.Click
Dim tbl As DataTable = NorthwindDataSe t.Products
Dim rows() As DataRow
' Check if a product is selected.
If Not Me.ProductNameL istBox.Selected Index < 0 Then
Dim product As String =
Me.ProductNameL istBox.Selected Item.Row.Item(" ProductName")
Dim company As String = Me.CompanyNameC omboBox.Text
' Return the data row from the selected Product in the list
box.
rows = tbl.Select("Pro ductName = '" & product.Replace ("'",
"''") & "'")
AddData(rows(0) , company)
Else
MessageBox.Show ("Please select a product.", "Actions Pane",
MessageBoxButto ns.OK)
End If
'LoadTables()
End Sub
End Class
///
By the way, this comes from an an tutorial exercise in MSDN2 at this
address;
http://msdn2.microsoft.com/library/m...US,VS.80).aspx
I would expect it to work. All code is copied from the exercise?