예제 #1
0
        private void toolBar1_ButtonClick(object sender,
                                          System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            try
            {
                if (e.Button == toolBarButtonCopy)
                {// copy to clipboard.
                    if (dataGridView1.SelectedCells.Count > 0)
                    {
                        dataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;

                        Clipboard.SetDataObject(
                            this.dataGridView1.GetClipboardContent());
                    }
                }
                else if (e.Button == toolBarButtonSave)
                {
                    if (m_seriesList.ReadOnly || m_seriesList.Count > 1)
                    {
                        return;
                    }

                    m_seriesList.Save();
                }
                else if (e.Button == toolBarButtonExcel)
                {
                    string tmpFilename = FileUtility.GetTempFileName(".csv");

                    //DataTableOutput.Write(this.table, tmpFilename, false);
                    DataTableOutput.Write(this.table, tmpFilename, false, false);
                    System.Diagnostics.Process.Start(tmpFilename);
                }
                else if (e.Button == toolBarButtonPaste)
                {
                    this.pasteToolStripMenuItem_Click(this, EventArgs.Empty);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor = Cursors.Default;
        }