Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
570
Possible bug in UltraGrid ?
posted

 Hi all !

I have created a method (see below) that associates a value list to a grid (WPF 2008, Vol. 2, .Net 2.0, VS 2005 SP1).

Without changing any code line, this method throws sometimes at runtime the exception:

"Key not found Parametername: key"

in code line

band.Columns[displayColumn].Style ...

 Also the object array

  Object[ colObj2 = band.Columns.All;

 is sometimes empty, although debbuging band.Columns.All delivers an non empty array.

 

 But when exchanging the code line (in the method)

UltraGridBand band = grid.Rows.Band;  

 by

UltraGridBand band = grid.DisplayLayout.Bands[0];

 the exception will never thrown !

 In my opinion a bug.

Regards,

Claus

 

 

        /// <summary>
        /// Creates a value list for the display column of a specified grid.
        /// </summary>
        /// <param name="grid">the grid</param>
        /// <param name="vlistName">the name of the value list to be created</param>
        /// <param name="displayColumn"></param>
        /// <param name="dataColumn"></param>
        /// <param name="source">the datasource which items should be filled into the value list</param>
        /// <param name="addToColumn"></param>
        private bool CreateValueListForOvertakeableColumns(ref UltraGrid grid, String vlistName, String displayColumn, String dataColumn, UltraDataSource source, bool addToColumn) {
            ValueList       vlist = null;
            bool     vlistCreated = false;

            if (grid != null && source != null) {
                try {
                    UltraGridBand band = grid.Rows.Band;               
                    String key = grid.Rows.Band.Key;         

       
                    Object[ colObj2 = band.Columns.All;         <- in some runtime cases the object array is empty !

                 
                    bool r1 = !(grid.DisplayLayout.ValueLists.Exists(vlistName));

                    if (r1) {
                        vlist = new ValueList();
                        vlist.Key = vlistName;
                        grid.DisplayLayout.ValueLists.Add(vlist);

                        this.FillValueList(
                            this.columnNamesDataSource,
                            vlist,
                            DataSourceSchemaColumnNames.COLUMN_NAME,
                            DataSourceSchemaColumnNames.COLUMN_INDEX
                        );

                        this.AddEmptyRowToValueList(vlist, this.FREE_COLUMN_EMPTY_ROW, -1);

                     
                        if (addToColumn) {
                            band.Columns[displayColumn].Style            = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownValidate;
                            band.Columns[displayColumn].ValueList        = vlist;
                            band.Columns[displayColumn].AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend;
                            vlistCreated = true;
                        }

                    }
                } catch (Exception e) {
                    this.Logger.Error(ItemCartException.CANT_BUILD_OVERTAKEABLE_VALUE_LIST + e.Message);
                }
            }
            return vlistCreated;
        }
 

  • 469350
    Verified Answer
    Offline posted

     This sounds to me like a timing problem. Since I don't know when you are calling this method, it's impossible for me to say for sure. But my guess is that you are calling this method at some point before the grid has been fully initialized. It's also possible that this is occurring because your application is using multiple threads and you are trying to access the grid columns before the data has been marhsalled to the UI thread.