, 당신은 우리가 소유 VSTO 프로젝트, 워크 시트 SelectionChange 이벤트 예를 들어
을 처리 할 수 있어야합니다, 우리는 시작할 때 각 워크 시트의 OnChange 이벤트에 가입 :
private List<Excel.Worksheet> _Worksheets = new List<Excel.Worksheet>();
private void ThisWorkbook_Startup(object sender, System.EventArgs e)
{
foreach (Excel.Worksheet sheet in Worksheets) //Could test for sheet name here
{
_Worksheets.Add(sheet);
sheet.SelectionChange +=
new Excel.DocEvents_SelectionChangeEventHandler(Sheet_SelectionChange);
}
}
같은
그런 다음 핸들러의를 ActiveCell을 얻을 수 있어야 뭔가 :
Excel.Range activeCell = (Excel.Range) this.Application.ActiveCell;
//get the cell value (or other properties)
object value = rng.Value;
당신이 셀에 대한 참조가 있으면, 당신은 t를 얻을 수 있습니다 그는 this answer의 코드를 사용하여 주소를 지정합니다.
그러면 텍스트 상자의 값을 업데이트 할 수 있습니다.