开发者社区> 问答> 正文

C# 人员管理小系统 信息加入 不用数据库 DataGridView

C#人员管理小系统 有 namespace 人员管理

{
public class Person
{
public int id;//学号
public string name;//姓名
public int sex;//性别
public int age;//年龄
public DateTime time;//出生日期
}
}

然后需要添加20人的信息 不需要使用数据库 最后用DataGridView显示出来 怎么做?

展开
收起
a123456678 2016-03-24 11:27:37 2809 0
1 条回答
写回答
取消 提交回答
  • '创建一个显示textBox的列()
    Dim col1 As DataGridViewTextBoxColumn =New DataGridViewTextBoxColumn()
    col1.Name = "Name"
    col1.HeaderText = "姓名" '设置标题中显示的文本

    Dim col3 As DataGridViewTextBoxColumn = NewDataGridViewTextBoxColumn()
    col3.Name = "sex"
    col3.HeaderText = "性别"

    '将新建的列添加到控件中
    DataGridView1.Columns.Add(col1)
    DataGridView1.Columns.Add(col3)

    '添加行
    '创建新行
    Dim row As DataGridViewRow = NewDataGridViewRow()
    row.CreateCells(DataGridView1)
    '设置单元格的值
    row.Cells(0).Value = "张三"
    row.Cells(1).Value = "男"
    DataGridView1.Rows.Add(row)
    '添加第二行
    im row1 As String() = {"李四", "男"}
    DataGridView1.Rows.Add(row1)

    2019-07-17 19:12:26
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
2022 DTCC-阿里云一站式数据库上云最佳实践 立即下载
云时代的数据库技术趋势 立即下载
超大型金融机构国产数据库全面迁移成功实践 立即下载