.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

To display the index variable from combobox

Posted By:laptop charles       Posted Date: December 22, 2010    Points: 15    Category: Visual Studio    URL: http://www.dotnetspark.com  

Using one combobox and add 1 to 10 and select any one then display the item index value....
 

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 selecting_index
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            comboBox1.Items.Add("one");
            comboBox1.Items.Add("two");
            comboBox1.Items.Add("three");
            comboBox1.Items.Add("four");
            comboBox1.Items.Add("five");
            comboBox1.Items.Add("six");
            comboBox1.Items.Add("seven");
            comboBox1.Items.Add("eight");
            comboBox1.Items.Add("nine");
            comboBox1.Items.Add("ten");
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            MessageBox.Show(comboBox1.SelectedIndex.ToString());
        }


    }
}

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend