帮助:指定的参数已超出有效值的范围

cpfirst 2010-12-09 02:14:02
指定的参数已超出有效值的范围。参数名: “0”不是“index”的有效值。
隐藏

在 System.Windows.Forms.Design.ImageListDesigner.OriginalImageCollection.get_Item(Int32 index)
在 System.Windows.Forms.Design.ImageListDesigner.OriginalImageCollection.SetKeyName(Int32 index, String name)



代码:
this.imageList2.ImageStream = (ImageListStreamer) resources.GetObject("imageList2.ImageStream");

this.imageList2.Images.SetKeyName(0, "货物.png");
this.imageList2.Images.SetKeyName(1, "货车.png");
this.imageList2.Images.SetKeyName(2, "Mac_Folder_32.png");
this.imageList2.Images.SetKeyName(3, "Mac_Folder_12.png");
this.imageList2.Images.SetKeyName(4, "Mac_Folder_41.png");

不知道什么原因
...全文
619 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
laj0600310219 2010-12-10
  • 打赏
  • 举报
回复
应该是索引值的问题吧。。。。你那个0,1,2。。。。那些数字是从哪里来的?
tuzhenqiao 2010-12-09
  • 打赏
  • 举报
回复
跟踪调试下,,
wuyq11 2010-12-09
  • 打赏
  • 举报
回复
http://social.msdn.microsoft.com/Forums/zh-CN/2212/thread/6099c8d0-3e12-408f-9cba-71a1d466959d/
cpfirst 2010-12-09
  • 打赏
  • 举报
回复
源代码
using Business;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using WeightSystem;
namespace MineralMarketing
{
partial class GuideForm
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows 窗体设计器生成的代码

/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>


private void InitializeComponent()
{
this.components = new Container();
resources = new ComponentResourceManager(typeof(MineralMarketing.GuideForm));
this.imageList1 = new ImageList(this.components);
this.imageList2 = new ImageList(this.components);

this.imageList1.ImageStream = (ImageListStreamer) resources.GetObject("imageList1.ImageStream");
this.imageList1.TransparentColor = Color.Transparent;
this.imageList1.Images.SetKeyName(0, "货物.png");
this.imageList1.Images.SetKeyName(1, "货车.png");
.
.
this.imageList1.Images.SetKeyName(20, "报表1.jpg");

this.imageList2.ImageStream = (ImageListStreamer)resources.GetObject("imageList2.ImageStream");
this.imageList2.TransparentColor = Color.Transparent;
this.imageList2.Images.SetKeyName(0, "货物.png");
this.imageList2.Images.SetKeyName(1, "货车.png");
.
.
this.imageList2.Images.SetKeyName(20, "报表1.jpg");
base.AutoScaleDimensions = new SizeF(6f, 12f);
base.ResumeLayout(false);
base.PerformLayout();
}
private ImageList imageList1;
private ImageList imageList2;
private ComponentResourceManager resources;
#endregion
}
}

SetKeyName 就是不能使用函数设置
cpfirst 2010-12-09
  • 打赏
  • 举报
回复
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;

this.imageList1 = new ImageList(this.components);
this.imageList2 = new ImageList(this.components);
//this.imageList1.Images.SetKeyName(0, "货物.png");
this.imageList1.Images.SetKeyName(1, "货车.png");

指定的参数已超出有效值的范围。参数名: “1”不是“index”的有效值。

一克代码 2010-12-09
  • 打赏
  • 举报
回复
this.imageList2.Images.SetKeyName(0, "货物.png");
吧这个删了!

或者写this.imageList2.Images.SetKeyName(5, "货物.png");

111,093

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧