示例#1
0
        public static void FixPrompts(DataGridView view, int wordCol, int promptIdCol)
        {
            string promptType      = string.Empty;
            char   letter          = Strings.DefaultPromptLetter;
            int    promptTypeIndex = 0;

            //null out prompt id field
            for (int cnt = 0; cnt < view.RowCount - 1; cnt++)
            {
                view[promptIdCol, cnt].Value = null;
            }

            for (int cnt = 0; cnt < view.RowCount - 1; cnt++)
            {
                if (!view[wordCol, cnt].Value.Equals(null) && !view[wordCol, cnt].Value.Equals(""))
                {
                    int promptIdIndex = view.Columns[PromptTypeRow.IdColumnName].Index;

                    if (view.Columns[PromptTypeRow.TypeColumnName] != null)
                    {
                        promptTypeIndex = view.Columns[PromptTypeRow.TypeColumnName].Index;
                        promptType      = view[promptTypeIndex, cnt].Value as string;
                    }
                    else
                    if (view.Columns[ConfirmationPromptRow.OptionColumnName] != null)
                    {
                        //default confirmation
                        letter = Strings.DefaultConfirmationPromptLetter;
                    }

                    if (promptType != null && promptType.Length > 0)
                    {
                        letter = promptType.ToLower().Substring(0, 1)[0];
                        //JDL added fix to prevent letter from stepping on the confirmation reserved letter
                        if (letter == Strings.DefaultConfirmationPromptLetter)
                        {
                            letter = Strings.DefaultExitBridgePromptLetter; //JDK added a new prompt letter "x"
                        }
                    }
                    //Update prompt id's
                    CommonForm.CalculateDefaultPromptIdIfAppropriate(view, cnt, wordCol, promptIdCol, letter, false);
                }
            }
        }