DataGridViewCell.ContextMenuStrip 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
셀과 연결된 바로 가기 메뉴를 가져오거나 설정합니다.
public:
virtual property System::Windows::Forms::ContextMenuStrip ^ ContextMenuStrip { System::Windows::Forms::ContextMenuStrip ^ get(); void set(System::Windows::Forms::ContextMenuStrip ^ value); };
public virtual System.Windows.Forms.ContextMenuStrip ContextMenuStrip { get; set; }
public virtual System.Windows.Forms.ContextMenuStrip? ContextMenuStrip { get; set; }
member this.ContextMenuStrip : System.Windows.Forms.ContextMenuStrip with get, set
Public Overridable Property ContextMenuStrip As ContextMenuStrip
속성 값
셀과 연결된 ContextMenuStrip입니다.
설명
이 속성은 사용자가 셀을 마우스 오른쪽 단추로 클릭할 때 일반적으로 표시되는 바로 가기 메뉴를 나타냅니다.
DataGridView 컨트롤 DataSource 속성이 설정되거나 해당 VirtualMode 속성이 true이면 속성 값을 ContextMenuStrip 가져오면 컨트롤의 이벤트가 발생 CellContextMenuStripNeeded 하며 이벤트 처리기에 지정된 대로 속성의 DataGridViewCellContextMenuStripNeededEventArgs.ContextMenuStrip 값이 반환됩니다. 이벤트에 대한 처리기가 없는 경우 속성 값을 ContextMenuStrip 가져오면 이전에 지정한 값 또는 의 기본값 null이 반환됩니다.
이벤트 처리는 여러 셀에 CellContextMenuStripNeeded 대한 셀 ContextMenuStrip 값을 설정할 때 성능 저하를 방지하기 위해 대량의 데이터로 작업할 때 주로 유용합니다. 자세한 내용은 Windows Forms DataGridView 컨트롤의 크기를 조정하는 최선의 방법을 참조하세요.
이 속성을 변경하면 소유DataGridView하는 에서 이벤트가 발생 CellContextMenuStripChanged 합니다(있는 경우).
행 속성을 설정하거나 컨트롤의 RowContextMenuStripNeeded 이벤트를 처리 DataGridView 하여 개별 셀이 아닌 개별 행 ContextMenuStrip 에 대한 바로 가기 메뉴를 지정할 수도 있습니다. 셀 ContextMenuStrip 속성 설정은 행 ContextMenuStrip 속성 설정을 재정의하고 CellContextMenuStripNeeded 이벤트는 이벤트 및 행 ContextMenuStrip 속성 설정을 모두 RowContextMenuStripNeeded 재정의합니다. 그러나 행 바로 가기 메뉴가 재정의되지 않도록 셀 바로 가기 메뉴에 대해 를 지정할 null 수 있습니다.