I'm trying make a new user managing panel for my winform project. Basically i want to display a combobox which lets administrative user to determine role for other users in Role column of gridview. Combobox content has just 3 items such as "Admin" , "User" , "Client" but gives me a set of error overDataError event.
All i did was right clicking on the gridview. Then click on "Edit Columns" , on the opening panel, i choose "Role" column and changed its ColumnType property to DataGridViewComboBoxColumn . Then i added name of roles into Items property's collection as one per line.
image 1: http://i.stack.imgur.com/IbHrK.png
Below you can see my code, winform design and error messages. How can i make it work without giving error messages?
image 2: http://i.stack.imgur.com/ts1ew.jpg
image 3: http://i.stack.imgur.com/gGNsy.jpg
image 4: http://i.stack.imgur.com/WBqsm.jpg
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 XXX { public partial class UserManager : Form { public UserManager() { InitializeComponent(); } private void UserManager_Load(object sender, EventArgs e) { panel1.BackColor = Color.FromArgb(100, 88, 55, 55); // TODO: This line of code loads data into the 'xXXDataSet.users' table. You can move, or remove it, as needed. this.usersTableAdapter.Fill(this.xXXDataSet.users); } private void button3_Click(object sender, EventArgs e) { this.Close(); } private void button1_Click(object sender, EventArgs e) { } private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs anError) { MessageBox.Show("Error happened " + anError.Context.ToString()); if (anError.Context == DataGridViewDataErrorContexts.Commit) { MessageBox.Show("Commit error"); } if (anError.Context == DataGridViewDataErrorContexts.CurrentCellChange) { MessageBox.Show("Cell change"); } if (anError.Context == DataGridViewDataErrorContexts.Parsing) { MessageBox.Show("parsing error"); } if (anError.Context == DataGridViewDataErrorContexts.LeaveControl) { MessageBox.Show("leave control error"); } if ((anError.Exception) is ConstraintException) { DataGridView view = (DataGridView)sender; view.Rows[anError.RowIndex].ErrorText = "an error"; view.Rows[anError.RowIndex].Cells[anError.ColumnIndex].ErrorText = "an error"; anError.ThrowException = false; } } } }