You must Sign In to post a response.
  • Category: .NET

    Combobox items load in datagridview

    Combobox items load in datagridview But..... Condition is that every combobox having items except another combox selected item.
  • #763798
    Hai Ankush,
    Can you please elaborate your issue. Is it with the windows application? When showing the combobox in windows application inside the GridView, you need to use EditingControlShowing eventhandler for the GridView as:

    private void dg1_EditingControlShowing(object sender,
    DataGridViewEditingControlShowingEventArgs e)
    {
    // add the combobox
    }

    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #763799
    You can handle this in using javascript.

    On databind you can register the javascript on each drop down. In the javascript you can handle the condition.

    By Nathan
    Direction is important than speed

  • #763800
    Hello pavan...

    I know the even...
    But I did not get dsiplay after select items in combo box...


    Please check following code...

    string _szPredefineLbl = "1,2,3,4".Split(',');

    private void dgvPeriodMap_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
    {
    string[] szStandardLabel = null;
    string szAlreadyExistedValues = string.Empty;
    try
    {
    #region ... For standard label combobox...
    if (dgvPeriodMap.SelectedCells.Count > 0)
    {
    if (e.Control is ComboBox && dgvPeriodMap.SelectedCells[0].ColumnIndex == 1)
    {

    objCustomCombo = (ComboBox)e.Control;

    objCustomCombo.Items.Clear();
    objCustomCombo.Items.Add("");

    foreach (DataGridViewRow dr in dgvPeriodMap.Rows)
    {

    if (dr.Cells[1].Value != null)
    {
    if (dr.Cells[1].Value.ToString().Trim() != "")
    {
    if(szAlreadyExistedValues!="")
    szAlreadyExistedValues = szAlreadyExistedValues + "," + dr.Cells[1].Value.ToString().Trim();
    else
    szAlreadyExistedValues = dr.Cells[1].Value.ToString().Trim();
    }
    }
    }

    string[] szArrAlreadyExistedValues = szAlreadyExistedValues.Split(',');
    for (int iStdCnt = 0; iStdCnt < _szPredefineLbl.Length; iStdCnt++)
    {
    bool bResult = true;

    for (int iCount = 0; iCount < szArrAlreadyExistedValues.Length; iCount++)
    {
    if (szArrAlreadyExistedValues[iCount].Trim().ToLower() == _szPredefineLbl[iStdCnt].ToLower())
    {
    bResult = false;
    break;
    }

    }
    if (bResult)
    {

    objCustomCombo.Items.Add(_szPredefineLbl[iStdCnt]);
    // ((DataGridViewComboBoxColumn)dgvPeriodMap.Columns[1]).Items.Add(_szPredefineLbl[iStdCnt]);

    }
    }
    if (dgvPeriodMap.Rows[dgvPeriodMap.CurrentCell.RowIndex].Cells[1].Value != null)
    objCustomCombo.Items.Add(dgvPeriodMap.Rows[dgvPeriodMap.CurrentCell.RowIndex].Cells[1].Value);


    }


    }
    #endregion
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    }


Sign In to post your comments