LinksPersistInfo not work!

from:http://www1.devexpress.com/Support/Center/p/DB26046.aspx

This code works only when called from within InitializeComponent() method. If it is invoked later it won't add anything visually (skinItm is BarSubItem placed on an XtraBar).

BarButtonItem tubo = new DevExpress.XtraBars.BarButtonItem();

tubo.Caption = "XXX";

tubo.Name = "Meho";

barManager.Items.Add(tubo);

skinItm.LinksPersistInfo.Add(new LinkPersistInfo(tubo));
<-     Reviewed by DevExpress Team         2006/8/9 5:50:52
<-     Processed (By Design) by DevExpress Team         2006/8/9 10:14:06

Please modify your code as shown below.

Old code:

[C#]
skinItm.LinksPersistInfo.Add(new LinkPersistInfo(tubo));

New code:

[C#]
skinItm.ItemLinks.Add(tubo);

We also advise that you review the AddBarItemLinks tutorial project shipped with the XtraBars.

Thank you,
Nick
->     Reactivated by Miha Markic         2006/8/9 10:19:19

Ok, thanks.
A note here: my old code (bad or good) was working in 6.1.x and it doesn't work anymore so it could be considered as a breaking change and thus the change could be documented in what's new section.
<-     Processed (By Design) by DevExpress Team         2006/8/9 12:51:37

Please try to surround your old code with the BarManager.BeginInit / BarManager.EndInit method similar to the code in the InitializeComponent method. The problem should disappear.

Thank you,
Nick
->     Reactivated by Miha Markic         2006/8/9 12:56:47

Hi Nick. Sure, I have no problems now and I will happily embrace the proper way via ItemLinks. I was just commenting that it might be good thing to leave a note in what's new section to avoid other people having the same problem.
<-     Processed (By Design) by DevExpress Team         2006/8/10 19:03:29

Hi Miha,

A true developer doesn't need any documentation; source code (or .NET Reflector) is enough :-) So why does one worry about a "What's New"? ;-)

The XtraBars' documentation suggests using either ItemLinks.Add or AddLink method to add menu items programmatically. Here is the quote from the documentation in regard to the LinksPersistInfo property:

This member supports the .NET Framework infrastructure and cannot be used directly from your code.
http://documentation.devexpress.com/#WindowsForms/DevExpressXtraBarsBarLinksPersistInfotopic

I personally don't see any reason for including a similar note into the What's New document.

Thank you,
Nick

P.S.
Miha, just between you and me :-), you can use the LinksPersistInfo.Add method, if you want the added item links to persist after the end-user resets a toolbar (Quick Customize | Reset Toolbar). Please don't forget to wrap the LinksPersistInfo.Add calls with BeginInit/EndInit as suggested above. But please keep this in secret, since it is an undocumented feature and for me it might be difficult to support it if anyone starts using it. :-)

N.

转载于:https://www.cnblogs.com/luoyaoquan/archive/2011/07/20/2111684.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值