예제 #1
0
        /*****************************************************************************
        *  FUNCTION:  HighlightData
        *  Description:
        *  Parameters:
        *****************************************************************************/
        public void HighlightData(String filterExpression, Color pColour)
        {
            DataRow[] rows;
            DataView  dv;
            DataTable sortedTable;
            String    ColumnName;
            int       i, count, index;

            try
            {
                dv          = tableSource.DefaultView;
                sortedTable = dv.ToTable();
                rows        = sortedTable.Select(filterExpression);

                ColumnName = Helpers.GetFirstWord(filterExpression);

                if (rows != null && rows.Count() > 0)
                {
                    count = rows.Count();
                    for (i = 0; i < count; i++)
                    {
                        index = sortedTable.Rows.IndexOf(rows[i]);
                        dataGridView1.Rows[index].Cells[ColumnName].Style.BackColor = pColour;
                    }
                }

                //Add to the dictionary of highlight commands
                filterExpression = filterExpression.Replace(" ", "");
                if (HighlightInstructions.ContainsKey(filterExpression))
                {
                    HighlightInstructions[filterExpression] = pColour;
                }
                else
                {
                    HighlightInstructions.Add(filterExpression, pColour);
                }
            }
            catch (Exception e)
            {
                //throw new ArithmeticException();
            }
        }