Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# y会导致错误,我甚至尝试从我已经创建的“关于表单”复制和粘贴代码。对不起,我不能再写了。 using System; using System.Collections.Generic; using System.ComponentModel; using _C#_Winforms_Visual Studio_Visual Studio 2012 - Fatal编程技术网

C# y会导致错误,我甚至尝试从我已经创建的“关于表单”复制和粘贴代码。对不起,我不能再写了。 using System; using System.Collections.Generic; using System.ComponentModel; using

C# y会导致错误,我甚至尝试从我已经创建的“关于表单”复制和粘贴代码。对不起,我不能再写了。 using System; using System.Collections.Generic; using System.ComponentModel; using ,c#,winforms,visual-studio,visual-studio-2012,C#,Winforms,Visual Studio,Visual Studio 2012,y会导致错误,我甚至尝试从我已经创建的“关于表单”复制和粘贴代码。对不起,我不能再写了。 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Window

y会导致错误,我甚至尝试从我已经创建的“关于表单”复制和粘贴代码。对不起,我不能再写了。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CS10AboutForm.cs
{
    public partial class frmAbout : Form
    {
        public frmAbout()
        {
            InitializeComponent();
        }



        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CS10.cs
{
    class frmAbout
    {
        internal void ShowDialog()
        {
            throw new NotImplementedException();
        }
    }
}
namespace CS10.cs
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void lblEdit_Click(object sender, EventArgs e)
        {

        }

        private void menuStrip2_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {

        }

        private void addBookToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Add a new book to the list
            if (cboBooks.Text != "")
            {
                cboBooks.Items.Add(cboBooks.Text);
                cboBooks.Text = "";
            }
            else
            {
                MessageBox.Show("Enter a book to add", "Missing data",
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            cboBooks.Focus();

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void mnuEditRemove_Click(object sender, EventArgs e)
        {
            // Remove the selected book from the list
            if (cboBooks.SelectedIndex != -1)
            {
                cboBooks.Items.RemoveAt(cboBooks.SelectedIndex);
            }
            else
            {
                MessageBox.Show("First select a book to remove",
                    "No selection made", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

        }

        private void mnuEditClear_Click(object sender, EventArgs e)
        {
            // Clear the book list
            DialogResult responseDialogResult;

            responseDialogResult = MessageBox.Show("Clear the book list?",
                "Clear book list", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (responseDialogResult == DialogResult.Yes)
            {
                cboBooks.Items.Clear();
            }

        }

        private void mnuEditCount_Click(object sender, EventArgs e)
        {
            // Display a count of the books on the list
            MessageBox.Show("The number of book types is " + cboBooks.Items.Count.ToString());

        }

        private void mnuHelpAbout_Click(object sender, EventArgs e)
        {
            // Create an instance and display frmAbout 
            frmAbout frmAboutObj = new frmAbout();
            frmAboutObj.ShowDialog();   //.ShowDialog displays as a Model Form

        }

        private void mnuFileExit_Click(object sender, EventArgs e)
        {
            this.Close();

        }

        private void mnuFilePrintPreview_Click(object sender, EventArgs e)
        {
            // Begin print preview by assigning PrintDocument
            printPreviewDialog1.Document = printDocument1;
            printPreviewDialog1.ShowDialog();

        }

        private void mnuFilePrint_Click(object sender, EventArgs e)
        {
            // Print by calling the Print method
            printDocument1.Print();
        }
        private void printDocument1_PrintPage(object sender,
               System.Drawing.Printing.PrintPageEventArgs e)
        {
            // Handle printing and print previews
            // printPreviewDialog1.ShowDialog() and printDocument1.Print() trigger
            //  PrintPage event.

            Font printFont = new Font("Arial", 12);
            Font headingFont = new Font("Arial", 14, FontStyle.Bold);
            float fltLineHeight = printFont.GetHeight();
            float fltPrintX = e.MarginBounds.Left;
            float fltPrintY = e.MarginBounds.Top;
            string strPrintLine;

            // Print Headings
            strPrintLine = "Book List ";
            e.Graphics.DrawString(strPrintLine, headingFont,
                Brushes.Black, fltPrintX, fltPrintY);
            strPrintLine = "By Lina";
            fltPrintY += fltLineHeight;
            e.Graphics.DrawString(strPrintLine, headingFont,
                Brushes.Black, fltPrintX, fltPrintY);

            // Leave a blank line between heading and detail line
            fltPrintY += fltLineHeight * 2;

            // Loop through the entire list
            for (int intIndex = 0; intIndex <= cboBooks.Items.Count - 1; intIndex++)
            {
                // Set up a line
                strPrintLine = cboBooks.Items[intIndex].ToString();
                // Send the line to the graphics page object
                e.Graphics.DrawString(strPrintLine, printFont,
                    Brushes.Black, fltPrintX, fltPrintY);

                // Increment the Y position for the next line
                fltPrintY += fltLineHeight;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void printPreviewDialog1_Load(object sender, EventArgs e)
        {

        }

        private void mnuFileExit_Click_1(object sender, EventArgs e)
        {
            this.Close();
        }

        private void mnuFilePrint_Click_1(object sender, EventArgs e)
        {

            // Call the print process by calling the Print method
            printDocument1.Print();

        }

        private void mnuFilePrintPreview_Click_1(object sender, EventArgs e)
        {
            // Begin print preview by assigning PrintDocument
            printPreviewDialog1.Document = printDocument1;
            printPreviewDialog1.ShowDialog();

        }

        private void mnuEditRemove_Click_1(object sender, EventArgs e)
        {
             // Remove the selected book from the list
            if (cboBooks.SelectedIndex != -1)
            {
                cboBooks.Items.RemoveAt(cboBooks.SelectedIndex);
            }
            else
            {
                MessageBox.Show("First select a book to remove",
                    "No selection made", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }


        }

        private void mnuEditClear_Click_1(object sender, EventArgs e)
        {
            // Clear the book list
            DialogResult responseDialogResult;

            responseDialogResult = MessageBox.Show("Clear the book list?",
                "Clear book list", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (responseDialogResult == DialogResult.Yes)
            {
                cboBooks.Items.Clear();
            }

        }

        private void mnuEditCount_Click_1(object sender, EventArgs e)
        {
            // Display a count of the books on the list
            MessageBox.Show("The number of book types is " + cboBooks.Items.Count.ToString());
        }

        private void mnuHelpAbout_Click_1(object sender, EventArgs e)
        {
            frmAbout frmAboutObj = new frmAbout();
            frmAboutObj.ShowDialog();   //.ShowDialog displays as a Modal Form
        }       
    }
}