简体   繁体   中英

How to create a lookup column when using data binding with Excel listobject

I am working on a VSTO project using excel 2010 and visual studio 2010.

I have successfully binded an excel listobject to a BindingList collection and I am trying to modify the listobject so that certain columns contains look up drop downs. Furthermore, I am trying to configure the particular column that it can translate the look up text to the look up value (integer).

I know the build in excel SharePoint list can achieve this. Question is, can we do it?

thanks

I resolved this issue by creating a special PropertyDescriptor for the lookup fields. The property descriptor will do a reversed lookup when the SetValue method is invoked by the listobject. It will do a forward lookup when the GetValue is invoked.

This way, as far as the object model is concerned, it is receiving the correct values and the excel is receiving the correct text. I can then use the excel validation to create drop downs on the UI.

The catch is that the lookup text needs to be unique. Otherwise, reversed lookup is impossible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM