如何在datagridview中复制结构值 [英] how to copy structure values in datagridview
本文介绍了如何在datagridview中复制结构值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我创建了一个结构,并在该结构的字段中分配了一些值,
现在我想在datagridview中复制该结构值
请帮助我
Hello
I have created one structure and assigned some values in fields of structure,
now i want to copy that structures values in datagridview
please help me
thanks in advance.
推荐答案
它可能会帮助您开始,
It might help you to start,
namespace DataGridViewTest
{
using System;
using System.Collections.Generic;
using System.Windows.Forms;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
MyStruct test1 = new MyStruct()
{
One = 2,
Two = 3
};
List<MyStruct> list = new List<MyStruct>();
list.Add(test1);
dataGridView1.DataSource = list;
}
}
public struct MyStruct
{
public int One { get; set; }
public int Two { get; set; }
}
}
:)
:)
这篇关于如何在datagridview中复制结构值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文