先上图,后说明。
图1
图1便是想要达到的效果。
1、先添加ImageComboBoxEdit控件,我将name改为imageComboBoxSplit,为了和后续代码相吻合。
2、添加ImageCollection控件。name设为imageCollection。
3、看图2,进入ImageCollection任务(鼠标点击ImageCollection上的小三角),点击EditImageCollect。
图2
4、看图3,点击添加按钮找到你想试用的图片,确定即可。
图3
5、进入ImageComboBoxEdit任务,选中Small Images下拉列表中的imageCollection(图4),然后点击下面的Edit items,进入图5。
图4
6、然后,添加成员,对右侧的三个杂项进行更改,其中ImageIndex改为你想要的图片的index。
图5
设计生成的部分代码如下:
-----------------------------------------------------------------代码分隔线----------------------------------------------------------------------------------------
//
// imageComboBoxSplit
//
this.imageComboBoxSplit.Location = new System.Drawing.Point(5, 3);
this.imageComboBoxSplit.Name = "imageComboBoxSplit";
this.imageComboBoxSplit.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.imageComboBoxSplit.Properties.Items.AddRange(new DevExpress.XtraEditors.Controls.ImageComboBoxItem[] {
new DevExpress.XtraEditors.Controls.ImageComboBoxItem("一分屏幕", "1", 0),
new DevExpress.XtraEditors.Controls.ImageComboBoxItem("四分屏幕", "4", 2),
new DevExpress.XtraEditors.Controls.ImageComboBoxItem("九分屏幕", "9", 5),
new DevExpress.XtraEditors.Controls.ImageComboBoxItem("十六分屏幕", "16", 6)});
this.imageComboBoxSplit.Properties.SmallImages = this.imageCollection;
this.imageComboBoxSplit.Size = new System.Drawing.Size(100, 20);
this.imageComboBoxSplit.TabIndex = 0;
this.imageComboBoxSplit.SelectedIndexChanged += new System.EventHandler(this.imageComboBoxSplit_SelectedIndexChanged);
//
// imageCollection
//
this.imageCollection.ImageStream = ((DevExpress.Utils.ImageCollectionStreamer)(resources.GetObject("imageCollection.ImageStream")));
this.imageCollection.Images.SetKeyName(0, "dlg_pane_view_light_1.jpg");
this.imageCollection.Images.SetKeyName(1, "dlg_pane_view_light_2.jpg");
this.imageCollection.Images.SetKeyName(2, "dlg_pane_view_light_4.jpg");
this.imageCollection.Images.SetKeyName(3, "dlg_pane_view_light_6.jpg");
this.imageCollection.Images.SetKeyName(4, "dlg_pane_view_light_8.jpg");
this.imageCollection.Images.SetKeyName(5, "dlg_pane_view_light_9.jpg");
this.imageCollection.Images.SetKeyName(6, "dlg_pane_view_light_16.jpg");
this.imageCollection.Images.SetKeyName(7, "dlg_pane_view_light_36.jpg");
this.imageCollection.Images.SetKeyName(8, "dlg_pane_view_light_64.jpg");