Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In datagridview as follows;


FacultyCode Course

RM REO / MFA


in datagridview cell how to store two values in single cell in datagridivew. how can i do


My code as follows;

C#
private void cb_course_KeyDown(object sender, KeyEventArgs e)
        {
          
            if (e.KeyCode == Keys.Enter)
            {
                int icol = Convert.ToInt16(datagridView.CurrentCellAddress.X.ToString());
                int irow = Convert.ToInt16(datagridView.CurrentCellAddress.Y.ToString());

                //checking the clashing
                for (int i = 0; i < datagridView.Columns.Count; i++)
                {
                    if (datagridView[i, irow].Value != null)
                    {
                        if (datagridView[i, irow].Value.ToString().Trim() == cb_Course.Text.ToString().Trim())
                        {
                            String Msg = "Selected course is already alloacted in " + datagridView.Columns[i].HeaderText;
                            DialogResult Results;
                            Results = MessageBox.Show(Msg, "Clashing", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            if (Results == System.Windows.Forms.DialogResult.No)
                            {
                                return;
                            }
                        }
                    }
                }
                cb_Course.Visible = false;
                cb_Course.Focus();
datagridView[datagridView.CurrentCellAddress.X, datagridView.CurrentCellAddress.Y].Value = cb_Course.Text;
                datagridView.Focus();
            }
            if (e.KeyCode == Keys.Escape)
            {
                cb_Course.Visible = false;
                datagridView.Focus();
            }
        }


in the above code in the datagridview cell store the single value in datagridview, but i want to store two values in the datagridview cell.

how can i do?

using my above what changes i would make to store two values in the datagridview single cell.

please help me.

Regards,
Narasiman P.
Posted
Updated 27-Feb-13 17:47pm
v2

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