Click here to Skip to main content
15,919,341 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Posted

1 solution

It might help you to start,

C#
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; }
    }
}


:)
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900