I have a row in excel I'd like to translate into an ObserveableCollection in C# for binding/event purposes, so all accessor classes know they're getting the latest data fr开发者_StackOverflow社区om the source excel sheet. How would this be done?
Clarification: I'm using an excel add-in project, not a workbook project, so am not sure whether or not XMLMappedRange Controls are an option.
Using VSTO you have a few options:
- From the Excel.Worksheet class, you can access the Worksheet.Change event.
- From the NamedRange class, you can access the NamedRange.Change event (which uses the Microsoft.Office.Interop.Excel.DocEvents_ChangeEventHandler delegate that you mentioned in another comment).
- The NamedRange class also supports simple, one-way databinding via the DataBindings property, an example of which is shown in the discussion How do I bind an array to a NamedRange.
- Another possibility is the XmlMappedRange control, which also supports databinding.
A good primer on using the NamedRange and XmlMappedRange can be found here: The VSTO Programming Model. A decent walkthrough using the NamedRange can be found in the Visual Studio Tools for Office (VSTO) 2005 Guided Tour.
I hope this helps...
Mike
You can add OnChanged in your range changed event.
精彩评论