Quantcast
Channel: Our ComponentOne » All Posts
Viewing all articles
Browse latest Browse all 14170

Reply To: Grid not accepting values entered by keyboard after edit MultiColumnDictionary

$
0
0

Hello Jeff,

Can you please replace the previous code by the given code snippet and see if this resolves all your issues. You don’t need to include 'AfterEdit’ event and modify the replace 'ValidateEdit’ event as given in the code below.


void _flex_ValidateEdit(object sender, C1.Win.C1FlexGrid.ValidateEditEventArgs e)
        {
            // check that we have a combo and a multi-column dictionary
            ComboBox cb = _flex.Editor as ComboBox;

            Hashtable hTable = null;
            IC1MultiColumnDictionary mcd = null;

            if (_flex.Cols[e.Col].DataMap.GetType() == typeof(Hashtable))
                hTable = _flex.Cols[e.Col].DataMap as Hashtable;
            else
                mcd = _flex.Cols[e.Col].DataMap as IC1MultiColumnDictionary;
            e.Cancel = false;
            if (cb != null && mcd != null || hTable != null)
            {
                // check that the current value is an integer
                double d = 0;
                //if (double.TryParse(cb.Text, NumberStyles.Integer, CultureInfo.CurrentCulture, out d))
                {
                    string text;
                    // look up entry using current content as key
                    if (mcd != null)
                    {
                        text = mcd.GetDisplayValue((int)d);

                        if (text.Length > 0)
                        {
                            // found, fix editor
                            cb.Text = text;
                        }
                        else
                        {
                            // not found, fail validation
                            e.Cancel = true;
                        }
                    }
                    else
                    {
                        foreach (int k in hTable.Keys)
                        {                             
                            if(hTable[k]==cb.SelectedItem.ToString())
                            {                                
                                _flex.SetData(e.Row, e.Col,k);
                                _flex.FinishEditing(true);           
                            }                        
                        }                    
                    }
                }
            }
        }

Hope this will help.

Regards,
Deepankar


Viewing all articles
Browse latest Browse all 14170

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>