How to create ItemData in C Sharp Archives - Tech Insights https://reactconf.org/category/how-to-create-itemdata-in-c-sharp/ Unveiling Tomorrow's Tech Today, Where Innovation Meets Insight Tue, 07 Oct 2014 17:40:00 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.2 https://i0.wp.com/reactconf.org/wp-content/uploads/2023/11/cropped-reactconf.png?fit=32%2C32&ssl=1 How to create ItemData in C Sharp Archives - Tech Insights https://reactconf.org/category/how-to-create-itemdata-in-c-sharp/ 32 32 230003556 How to create ItemData in C Sharp https://reactconf.org/how-to-create-itemdata-in-c-sharp/ https://reactconf.org/how-to-create-itemdata-in-c-sharp/#comments Tue, 07 Oct 2014 17:40:00 +0000 http://www.sqlneed.com/2014/10/07/how-to-create-itemdata-in-c-sharp/ In this article i will explain how to create ItemData. You need to create new project and name of the project is ItemDatainCSharp and add combobox control then create custom …

The post How to create ItemData in C Sharp appeared first on Tech Insights.

]]>
In this article i will explain how to create ItemData. You need to create new project and name of the project is ItemDatainCSharp and add combobox control then create custom class or structure and bind to the combobox control.

Create Class and give the name of class is ItemData and copy this code and paste


please give your comments


// Custom Structure or Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ItemDatainCSharp
{
    public struct ItemData
    {
        public intID;
        public stringEmpName;
        public ItemData(int_ID, string _EMName)
        {
            ID = _ID;
            EmpName = _EMName;
        }
        public overridestring  ToString()
        {
         return this.EmpName;
        }
       
    }
}
Open the form view code and Copy this code and paste.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ItemDatainCSharp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private voidForm1_Load(object sender, EventArgs e)
        {
            comboBox1.Items.Clear();
            comboBox1.Items.Add(new ItemData(101,“John”));
            comboBox1.Items.Add(new ItemData(102, “Ajay”));
        }
        private voidcomboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            MessageBox.Show(“Employee ID : “ + ((ItemData)comboBox1.SelectedItem).ID  + Environment.NewLine +
                “Employee Name : “ + ((ItemData)comboBox1.SelectedItem).EmpName.ToString());
        }
    }
}


The post How to create ItemData in C Sharp appeared first on Tech Insights.

]]>
https://reactconf.org/how-to-create-itemdata-in-c-sharp/feed/ 1 36