LinksPersistInfo not work!
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.