Exemplo n.º 1
0
        private void gridStatistics_KeyDown(object sender, KeyEventArgs e)
        {
            // Handle Ctrl + C for copy
            if (e.KeyCode == Keys.V && e.Control)
            {
                StringBuilder sb = new StringBuilder();
                foreach (DataGridViewRow row in gridStatistics.Rows)
                {
                    if (row.IsNewRow)
                    {
                        continue;
                    }

                    foreach (DataGridViewCell cell in row.Cells)
                    {
                        if (sb[sb.Length - 1] != '\n') // Not L10N
                        {
                            sb.Append('\t');           // Not L10N
                        }
                        sb.Append(cell.Value);
                    }
                    sb.Append('\n'); // Not L10N
                }
                try
                {
                    ClipboardEx.Clear();
                    ClipboardEx.SetText(sb.ToString());
                }
                catch (ExternalException)
                {
                    MessageDlg.Show(this, ClipboardHelper.GetOpenClipboardMessage(Resources.RTDetails_gridStatistics_KeyDown_Failed_setting_data_to_clipboard));
                }
            }
        }
        /// <summary>
        /// Copy the data from the curves in the ZedGraphControl to the clipboard.
        /// </summary>
        public static void CopyGraphData(ZedGraphControl zedGraphControl)
        {
            var graphData = GraphData.GetGraphData(zedGraphControl.MasterPane);

            if (graphData.Panes.Count == 0)
            {
                return;
            }
            try
            {
                ClipboardEx.Clear();
                ClipboardEx.SetText(graphData.ToString());
            }
            catch (ExternalException)
            {
                MessageBox.Show(ClipboardHelper.GetOpenClipboardMessage(Resources.CopyGraphDataToolStripMenuItem_CopyGraphData_Failed_setting_data_to_clipboard), Program.Name);
            }
        }