当前位置:网站首页>C# Winform开发 弹出式输入框 文本框
C# Winform开发 弹出式输入框 文本框
2022-07-22 11:07:00 【多层感只鸡】
这个组件在Microsoft.VisualBasic中,可以直接调用这句话,然后提示会提醒你然后点击就可以添加这个命名空间了。
在WInform中使用的实例:
string str = Interaction.InputBox("请输入目标的名字", "重命名文件夹", "在这里输入", -1, -1);
str就可以得到文本框的输入的内容,Interaction.InputBox()中几个参数可以预置为以上,也可以自行调整
点击取消和X都是不会得到str的值的,可以用str.Length == 0来判断出本次操作无效,接着就可以通过拿到的参数来实现需要的功能了,这里实现了一个重命名。
private void 重命名ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (ControlFileClass.IsFolder(menupath))
{
string str = Interaction.InputBox("请输入目标的名字", "重命名文件夹", "在这里输入", -1, -1);
if (str.Length == 0)
{
MessageBox.Show("没有输入,无效操作");
return ;
}
Directory.SetCurrentDirectory(rootpath + @"\" + "txt");
Directory.Move(ControlFileClass.GetFileName(menupath), str);//使用filename但是get的是folder
Directory.SetCurrentDirectory(rootpath);
分区刷新(rootpath + @"\" + "txt"); ;
}
else
{
string str = Interaction.InputBox("请输入目标的名字", "重命名文件", "在这里输入,请注意需要同时输入后缀名", -1, -1);
if (str.Length == 0)
{
MessageBox.Show("没有输入,无效操作");
return;
}
string filename = ControlFileClass.GetFileName(menupath);
string foldername = ControlFileClass.GetFileName(ControlFileClass.GetFolderPath(menupath));
Directory.SetCurrentDirectory(rootpath + @"\" + "txt" + @"\" + foldername);
Directory.Move(filename, str);//使用filename但是get的是folder
Directory.SetCurrentDirectory(rootpath);
知识库刷新(fenquname);
}
}
边栏推荐
- [lttng learning journey] - simply add a trace point to the user program
- Juc-6.3-concurrency container queue
- Leetcode notes (I) backtracking
- 四六级英语听力发射无线广播系统在广东海洋大学阳江校区的应用
- shell远程执行命令
- pytorch 自定义数据集载入(标签在csv文件里)
- Wechat applet comprehensive case practice 1
- Chapter 7: login using JWT token
- 【PyTorch深度学习实践】学习笔记 第四节 反向传播
- YOLO9000: Better, Faster, Stronger
猜你喜欢
云报传媒广场数字电视转模拟系统设计分享
On the characteristics of filter pseudo protocol
英语四六级听力有线传输无线发射系统方案
Buuctf breakthrough diary 02-- [hctf 2018] warmup1
[LTTng学习之旅]------core concepts 拾遗
[GXYCTF2019]BabyUpload1
YOLO9000: Better, Faster, Stronger
Relationship and difference between session and cookie
[lttng learning journey] - trace control -- advanced
JUC-6.3-并发容器-队列
随机推荐
简单句(Simple sentences)-one
Process control - if statement
Makefile心得
已经两点经纬度,计算两点之间距离
近期的研究方向
Interview of 2020 Central South University information and communication summer camp
RPM package management - Yum online management - IP address configuration and network Yum source
毕设路线—pytorch环境下的深度学习的高光谱图像分类问题
extern “C“的作用
Buuctf breakthrough diary --[mrctf2020]ez_ bypass1
About dichotomy
Application & rich text editor & file upload
4. Text editor
[lttng learning journey] - lttng features
两台服务器之间拷贝文件-scp方法
人类群星网站收集计划--Michael Kerrisk
NVIDIA CLARA资料
Process control
[LTTng学习之旅]------Trace控制--进阶
Buuctf breakthrough diary 04 -- [strong net cup 2019] casual note 1