Esempio n. 1
0
        /// <summary>
        /// 
        /// </summary>
        public static void PasteClipBoardToInsertionRow(IGrid grid)
        {
            string data = m_copyDataForPaste;
            if (!string.IsNullOrEmpty(data))
            {
                InsertionRow row = grid.GetInsertionRow();
                if (row != null)
                {
                    row.BeginEdit();
                    string[] ss = data.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                    if (ss.Length < 2)
                        return;
                    Dictionary<int, string> columnNames = new Dictionary<int,string>();
                    string[] sss = ss[0].Split(new char[] { '\t' }, StringSplitOptions.None);
                    {
                        for (int j = 0; j < sss.Length; ++j)
                        {
                            columnNames[j] = sss[j];
                        }
                    }
                    for (int i = 1; i < ss.Length; )
                    {
                        sss = ss[i].Split(new char[] { '\t' }, StringSplitOptions.None);
                        for (int j = 0; j < sss.Length; ++j)
                        {
                            try
                            {
                                if (grid.Columns[columnNames[j]] == null)
                                    continue;

                                if (string.IsNullOrEmpty(sss[j]))
                                {
                                    row.Cells[columnNames[j]].Value = null;
                                }
                                else
                                {
                                    object r = ConvertHelper.ChangeType(sss[j], grid.Columns[columnNames[j]].DataType);
                                    row.Cells[columnNames[j]].Value = r;
                                }
                            }
                            catch (Exception ex)
                            {
                                ExceptionProcess.ProcessWithNotify(ex);
                            }
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 
        /// </summary>
        public static void CancelEditCurrentDataRow(IGrid grid)
        {
            // ��enter Edit Mode �󣬲��Ҳ����ڵ��б�����ִ���
            try
            {
                Xceed.Grid.CellRow row = grid.CurrentRow as Xceed.Grid.CellRow;
                if (row != null && row.IsBeingEdited)
                {
                    row.CancelEdit();
                }

                InsertionRow insertionRow = grid.GetInsertionRow();
                if (insertionRow != null) //��һ����Edit && insertionRow.IsBeingEdited)
                {
                    insertionRow.CancelEdit();

                    // bug in xceed?
                    foreach (Xceed.Grid.Cell cell in insertionRow.Cells)
                    {
                        cell.ResetReadOnly();
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionProcess.ProcessWithResume(ex);
            }
        }