ListRanges Enum
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Specifies the range of a ListObject that has changes.
This enumeration supports a bitwise combination of its member values.
public enum class ListRanges
[System.Flags]
public enum ListRanges
[<System.Flags>]
type ListRanges =
Public Enum ListRanges
- Inheritance
-
ListRanges
- Attributes
Fields
DataBodyRange | 2 | The change occurred in the DataBodyRange of the ListObject. |
HeaderRowRange | 1 | The change occurred in the HeaderRowRange of the ListObject. |
None | 0 | The change did not occur in the DataBodyRange, HeaderRowRange, or TotalsRowRange. |
TotalsRowRange | 4 | The change occurred in the TotalsRowRange of the ListObject. |
Examples
The following code example creates a ListObject and an event handler for the Change event. The event handler uses the ListRanges values to display the location of a changed range. To raise the Change event, add text to one of the cells in the ListObject and then press ENTER.
This example is for a document-level customization.
private void ListObject_Change()
{
Microsoft.Office.Tools.Excel.ListObject list1 =
this.Controls.AddListObject(
this.Range["A1", "C4"], "list1");
list1.Change += new Microsoft.Office.Tools.Excel.
ListObjectChangeHandler(list1_Change);
}
void list1_Change(Microsoft.Office.Interop.Excel.Range
targetRange, Microsoft.Office.Tools.Excel.ListRanges
changedRanges)
{
string cellAddress = targetRange.get_Address(
Excel.XlReferenceStyle.xlA1
);
switch (changedRanges)
{
case Microsoft.Office.Tools.Excel.ListRanges.DataBodyRange:
MessageBox.Show("The cells at range " + cellAddress +
" in the data body changed.");
break;
case Microsoft.Office.Tools.Excel.ListRanges.HeaderRowRange:
MessageBox.Show("The cells at range " + cellAddress +
" in the header row changed.");
break;
case Microsoft.Office.Tools.Excel.ListRanges.TotalsRowRange:
MessageBox.Show("The cells at range " + cellAddress +
" in the totals row changed.");
break;
default:
MessageBox.Show("The cells at range " + cellAddress +
" changed.");
break;
}
}
WithEvents ChangeList As Microsoft.Office.Tools.Excel.ListObject
Private Sub ListObject_Change()
ChangeList = Me.Controls.AddListObject( _
Me.Range("A1", "C4"), "ChangeList")
End Sub
Sub List1_Change(ByVal targetRange As _
Microsoft.Office.Interop.Excel.Range, _
ByVal changedRanges As Microsoft.Office.Tools.Excel.ListRanges) _
Handles ChangeList.Change
Dim cellAddress As String = targetRange.Address( _
ReferenceStyle:=Excel.XlReferenceStyle.xlA1)
Select Case changedRanges
Case Microsoft.Office.Tools.Excel.ListRanges.DataBodyRange
MsgBox("The cells at range " & cellAddress & _
" in the data body changed.")
Case Microsoft.Office.Tools.Excel.ListRanges.HeaderRowRange
MsgBox("The cells at range " & cellAddress & _
" in the header row changed.")
Case Microsoft.Office.Tools.Excel.ListRanges.TotalsRowRange
MsgBox("The cells at range " & cellAddress & _
" in the totals row changed.")
Case Else
MsgBox("The cells at range " & cellAddress & _
" changed.")
End Select
End Sub
Remarks
The ListRanges enumeration is used by one of the parameters of the ListObjectChangeHandler delegate.