Hello. I have a form with a combobox that is populated with client names. But to insert a record ina a table I use the client code. What I want to do is create a special combobox with an extra property called Cods, which will be populated at the same time that ComboBox Items are populated with the names. So, when I select a user name, then the Combobox.SelectedIndex can be used to sinchronize names and codes for the combobox. I have started creating this user control:
What I don't know how to do is how to use variable index to get the correspondig valuein property Cods. Can anybody help me?
Thanks.
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.ComboBox;
namespace Tools
{
public partial class BdComboBox : UserControl
{
public BdComboBox()
{
InitializeComponent();
}
public ObjectCollection Cods { get; set; }
public void Sincroniza()
{
int index = this.comboBox1.SelectedIndex;
}
}
}
Thanks.