c#.winform,datagridview,数组,绑定,字符串,字符串数组绑定datagridview显示,长度,显示数组内容
2008-05-25 15:47
531 查看
使用字符串数组绑定datagridveiw控件的时候,默认显示的是字符串的长度,是因为网格查找数组对象的第一个属性,并且显示这个属性,长度就是第一个属性,可是我们要显示的是字符串的内容。
下面首先是默认显示图片和代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
public partial class Form10 : Form
public Form10()
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
Item[] items = new Item[]
this.dataGridView1.DataSource = items;
}
}
class Item
private string _text;
public string Text
get }
public Item(string text)
this._text = text;
}
}
}
下面首先是默认显示图片和代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
public partial class Form10 : Form
public Form10()
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
Item[] items = new Item[]
this.dataGridView1.DataSource = items;
}
}
class Item
private string _text;
public string Text
get }
public Item(string text)
this._text = text;
}
}
}
相关文章推荐
- [新手]C# winform 用dataGridView显示数据库内容
- C#Winform基础 显示选中行的第一列单元格的内容,datagridview控件
- C#中使用DataGridView控件显示数组中的内容
- C#Winform基础 显示选中行的第一列单元格的内容,datagridview控件
- c# winform项目treeview控件绑定本地电脑磁盘信息,读取文件夹信息,显示文件夹内文件内容
- c# winform项目treeview控件绑定本地电脑磁盘信息,读取文件夹信息,显示文件夹内文件内容
- 有一个字符数组的内容为:"student a am i",请你将数组的内容改为"i am a student". 要求: 不能使用库函数。只能开辟有限个空间(空间个数和字符串的长度无关)。
- c# winform label 内容靠右,先设置自动长度为false才行
- 项目经历——截取超出长度的字符串,鼠标移动到上面显示全部内容
- C#中/winform中,给已经绑定数据的datagridview后台动态添加新行
- 高效率的C#截取指定长度字符串,大于指定长度的,在末尾显示指定字符,默认为"..."
- 根据宽根据宽度来决定显示的字符串长度 (C#,VS2005)度来决定显示的字符串长度 (C#,VS2005)
- 有一个字符数组的内容为:"student a am i",请你将数组的内容改为"i am a student". 要求: 不能使用库函数。只能开辟有限个空间(空间个数和字符串的长度无关)
- C# Winform DataGridView中利用WebClient异步加载显示网络图片
- [转]Winform(C#)DataGridView显示Tooltip
- C# Winform 中webBrowser显示html内容时禁止错误提示的方法
- 关于C# Winform dataGridView显示时没有默认选中以及dataGridView添加DataTable中的数据
- WinForm DataGridView 绑定泛型List(List<T>)/ArrayList不显示的原因和解决
- JAVA中查询一个词在内容中出现的次数、判断集合中是否包含关键字、查询字符串数组单个字符的长度
- 关于C#中货币类型和数值类型、字符串类型的转化和在DataGridView中的显示问题: