Add style to Style Manager

2489
2
Jump to solution
04-30-2015 04:35 AM
BarbaraSchneider1
New Contributor III

I would like to add a style to the Style Manager using ArcObjects. I guess this is done using IStyleImporter.Import. However, I haven't found a sample how to get a StyleImporter object. I tried to cocreate it, but it isn't possible. Can anyone help?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
ChrisKushnir
New Contributor III

Haven't tried it, but what about the StyleGallery ?

e.g.

...

var mxDocument = application.Document as IMxDocument;

var styleGallery = mxDocument.StyleGallery;

styleGallery.LoadStyle(filename, null);

or,

var styleGalleryStorage = mxDocument.StyleGallery as IStyleGalleryStorage;

styleGalleryStorage.AddFile(filename);

See:

ArcObjects 10 .NET SDK Help - IStyleGallery

ArcObjects 10 .NET SDK Help - IStyleGalleryStorage

View solution in original post

0 Kudos
2 Replies
ChrisKushnir
New Contributor III

Haven't tried it, but what about the StyleGallery ?

e.g.

...

var mxDocument = application.Document as IMxDocument;

var styleGallery = mxDocument.StyleGallery;

styleGallery.LoadStyle(filename, null);

or,

var styleGalleryStorage = mxDocument.StyleGallery as IStyleGalleryStorage;

styleGalleryStorage.AddFile(filename);

See:

ArcObjects 10 .NET SDK Help - IStyleGallery

ArcObjects 10 .NET SDK Help - IStyleGalleryStorage

0 Kudos
BarbaraSchneider1
New Contributor III

Thanks, Chris!

IStyleGalleryStorage.AddFile() is used to add a style to Style Manager.

IStyleGallery.LoadStyle() is used to load a style from Style Gallery that is already present in Style Manager.

0 Kudos