如何限制在VB6中添加重复项

时间:2014-06-13 11:42:31

标签: vb6 activereports componentone

我有一个用VB6编写的应用程序。

此应用程序包含一个包含foreach循环的代码段的文件。在此循环中,方法是将控件添加到节(节是报表中的区域)。

我正在尝试实现以下功能:

theheader中添加headerSection后,tt将不再添加theHeader,但此代码段无法执行此操作。我哪里错了?

For Each thisColumn As Column In theColumns
  If thisColumn.Type = Column.ColumnType.Description Then
     AddDescriptionColumn(thisColumn, startColumnAt, headerTop)
  End If
 Private Sub AddDescriptionColumn(ByVal ColumnToAdd As Column, ByRef LeftPosition As Single, ByVal HeaderTop As Single)

  'Get report sections
  Dim headerSection As ActiveReports.Section = _theActiveReport.Sections(PageHeaderName)

  'Add column header text
  Dim theHeader As New ActiveReports.Label
  theHeader.Name = "lblDescription"
  theHeader.Text = ColumnToAdd.DisplayCaption
  theHeader.Font = ColumnToAdd.HeaderFont
  theHeader.Location = New PointF(LeftPosition, HeaderTop)
  theHeader.Size = New SizeF(columnWidth, _columnHeaderHeight)
  If TextHeight(ColumnToAdd.DisplayCaption, theHeader.Font, columnWidth) > _columnHeaderHeight Then
     theHeader.VerticalAlignment = ActiveReports.VerticalTextAlignment.Top
  Else
     theHeader.VerticalAlignment = ActiveReports.VerticalTextAlignment.Bottom
  End If
  theHeader.BackColor = Color.Transparent
  theHeader.MultiLine = True
  theHeader.WordWrap = True
  theHeader.Visible = True
  headerSection.Controls.Add(theHeader)

0 个答案:

没有答案