Ejemplo n.º 1
0
        private void FillMain()
        {
            int selectedIdx = gridMain.GetSelectedIndex();

            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            gridMain.ListGridColumns.Add(new GridColumn("Abbr", 75));
            gridMain.ListGridColumns.Add(new GridColumn("Note", 600));
            gridMain.ListGridRows.Clear();
            if (listCat.SelectedIndex == -1)
            {
                gridMain.EndUpdate();
                return;
            }
            GridRow row;

            _listNotes = _listNotes.OrderBy(x => x.ItemOrder).ToList();
            foreach (QuickPasteNote note in _listNotes)
            {
                if (note.QuickPasteCatNum != _listCats[listCat.SelectedIndex].QuickPasteCatNum)
                {
                    continue;
                }
                row = new GridRow();
                row.Cells.Add(string.IsNullOrWhiteSpace(note.Abbreviation)?"":"?" + note.Abbreviation);
                row.Cells.Add(note.Note.Replace("\r", "").Replace("\n", "").Left(120, true));
                row.Tag = note;
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
            if (selectedIdx == -1)           //Select the last option.
            {
                gridMain.SetSelected(gridMain.ListGridRows.Count - 1, true);
                gridMain.ScrollToEnd();
            }
            else if (selectedIdx < gridMain.ListGridRows.Count)           //Select the previously selected position.
            {
                gridMain.SetSelected(selectedIdx, true);
            }
        }