NamedRange.Comment Property (2007 System)
Gets a Comment that represents the comment associated with the cell in the upper left corner of the NamedRange control.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)
Syntax
'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property Comment As Comment
'Usage
Dim instance As NamedRange
Dim value As Comment
value = instance.Comment
[BrowsableAttribute(false)]
public Comment Comment { get; }
[BrowsableAttribute(false)]
public:
property Comment^ Comment {
Comment^ get ();
}
public function get Comment () : Comment
Property Value
Type: Comment
A Comment that represents the comment associated with the cell in the upper left corner of the NamedRange control.
Examples
The following code example creates a NamedRange and adds a comment to the cell. It then displays a message box that causes the comment to become visible if the user clicks OK.
This example is for a document-level customization.
Private commentRange As Microsoft.Office.Tools.Excel.NamedRange
Private Sub AddCommentToRange()
commentRange = Me.Controls.AddNamedRange( _
Me.Range("C3"), "setColumnRowRange")
Me.commentRange.AddComment("This is a comment.")
Dim comment1 As Excel.Comment = Me.commentRange.Comment
comment1.Visible = False
If MessageBox.Show("Display comment?", "Comment Test", _
MessageBoxButtons.OKCancel) = DialogResult.OK Then
comment1.Visible = True
End If
End Sub
Microsoft.Office.Tools.Excel.NamedRange commentRange;
private void AddCommentToRange()
{
commentRange = this.Controls.AddNamedRange(
this.Range["C3", missing], "setColumnRowRange");
this.commentRange.AddComment("This is a comment.");
Excel.Comment comment1 = this.commentRange.Comment;
comment1.Visible = false;
if (MessageBox.Show("Display comment?", "Comment Test",
MessageBoxButtons.OKCancel) == DialogResult.OK)
{
comment1.Visible = true;
}
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.