фсем превед,
в процессе написания snap-in для mmc столкнулся с следующей проблемой:
есть FormView, в нем висит TreeView. дабаляю в тривью иконки, происываю нодам идексы картинок. снапин компилиццо и прекрасно запускается, но упорно отказывается отображать иконки в тривью. оставляет просто пустое место.
пример не работающего кода:
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.ManagementConsole;
using System.ComponentModel;
using System.Security.Permissions;
using System.Collections;
using System.Windows.Forms;
using System.Drawing;
[assembly: PermissionSetAttribute(SecurityAction.RequestMinimum, Unrestricted = true)]
namespace NWC.PolicyConverter
{
[RunInstaller(true)]
public class InstallUtilSupport : SnapInInstaller
{
}
[SnapInSettings("{21111984-BD52-4661-8A27-424FEE1AE81A}",
DisplayName = "test",
Description = "test")]
public class PolicyConverterSnapIn : SnapIn
{
public PolicyConverterSnapIn()
: base()
{
this.RootNode = new ScopeNode();
this.RootNode.DisplayName = "Root";
FormViewDescription fvd = new FormViewDescription();
fvd.DisplayName = "snap-in UI";
fvd.ViewType = typeof(UIFormView);
fvd.ControlType = typeof(MyTreeView);
this.RootNode.ViewDescriptions.Add(fvd);
this.RootNode.ViewDescriptions.DefaultIndex = 0;
}
}
public class UIFormView : FormView
{
private MyTreeView ui = null;
public UIFormView()
{
}
protected override void OnInitialize(AsyncStatus status)
{
base.OnInitialize(status);
ui = (MyTreeView)this.Control;
ui.Dock = DockStyle.Fill;
}
}
public class MyTreeView : TreeView, IFormViewControl
{
UIFormView ParentForm = null;
private System.ComponentModel.IContainer components = null;
public MyTreeView()
: base()
{
this.ImageList = new ImageList();
this.ImageList.Images.Add(new Icon(@"c:\folder.ico"));
this.ImageList.Images.Add(new Icon(@"c:\folder.ico"));
this.ImageIndex = 0;
this.SelectedImageIndex = 1;
TreeNode Root = new TreeNode("Root node");
Root.ImageIndex = 0;
TreeNode SubNode1 = new TreeNode("SubNode1");
SubNode1.ImageIndex = 1;
TreeNode SubNode2 = new TreeNode("SubNode2");
SubNode2.ImageIndex = 1;
TreeNode SubNode21 = new TreeNode("SubNode21");
SubNode21.ImageIndex = 3;
SubNode2.Nodes.Add(SubNode21);
Root.Nodes.Add(SubNode1);
Root.Nodes.Add(SubNode2);
this.Nodes.Add(Root);
}
#region IFormViewControl Members
public void Initialize(FormView view)
{
this.ParentForm = (UIFormView)view;
}
#endregion
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
}
}
никто не сталкивался с такой проблемой? куда копать? отказаться от FormView и TreeView не представляеться возможным. надо есче заметить, что точно так же ведет себя ListView.
16.02.08 02:27: Перенесено модератором из '.NET' — Хитрик Денис