按钮应用(剪切,复制,粘贴)

本文详细介绍了如何使用C#编程语言,通过设置BackgroundImageLayout为Stretch来实现图片完全显示,并展示了如何在窗体中使用面板、文本框等控件进行多行文本编辑、复制、粘贴、格式设置以及实现滚动条功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

要实现图片完全显示设置:BackgroundImageLayout=Stretch
效果图:

这里写图片描述

滚动条的制作:

1 把工具栏中拖panel到窗体里面,然后设置其属性AutoScroll=true;

2 把工具栏中的TextBox拖到panel中,要实现多行设置其属性Multiline=true

3 右边的功能看下面代码:

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 jianqie
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private String stext = "";//用于保存输入的文本

        private void button1_Click(object sender, EventArgs e)
        {
            stext = textBox1.SelectedText;//剪切
            textBox1.SelectedText = "";
        }

        private void button3_Click(object sender, EventArgs e)
        {
            textBox1.SelectedText = stext;//粘贴
        }
        private void button2_Click(object sender, EventArgs e)
        {
            stext = textBox1.SelectedText;//复制
        }
        private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
        {

        }

        private void button5_Click(object sender, EventArgs e)
        {
            Application.Exit();//退出
        }



        private void button4_Click(object sender, EventArgs e)
        {
            textBox1.Font = new Font("隶书", 16);//文本格式
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值