在winform里
比如有一个textbox1,里有一段文本 To: oo By: xx Content: ...
然后我双击textbox1,就会弹出一个大的文本框上面有 取消 和 确定 按钮,
文本框里是textbox1的文本,并且To: By: Content: 是高亮状态(如果这个很麻烦的话 可以不实现).
可以在文本框里编辑文本 ,编辑完成后点击确定 会把textbox1的文本替换会弹出文本框里的文本
点击取消 则不变.
各位大大请问这个该如何实现呀?
比如有一个textbox1,里有一段文本 To: oo By: xx Content: ...
然后我双击textbox1,就会弹出一个大的文本框上面有 取消 和 确定 按钮,
文本框里是textbox1的文本,并且To: By: Content: 是高亮状态(如果这个很麻烦的话 可以不实现).
可以在文本框里编辑文本 ,编辑完成后点击确定 会把textbox1的文本替换会弹出文本框里的文本
点击取消 则不变.
各位大大请问这个该如何实现呀?
解决方案 »
- c# 关于暂停监听的问题
- 紧急,一个概率问题。基数越大,得到1的概率就越大,算法怎么写?
- 怎样做个“浏览”来选择文件夹,用哪个类?
- 怎么在richTextBox选中指定一行字符....
- 打上 SP2 后,在 VS.NET 中生成部署项目时出现“不可恢复的生成错误”
- 谁能给我C#版的issueVision,email:[email protected],万分感谢
- 除了VSS,还有什么版本控制器和VS.NET兼容好的?
- C#新人字符串模糊匹配的问题
- 新手的问题!
- 请教,开机后自动运行一C#程序,关机前自动关闭此C#程序如何实现?
- 为什么更新数据库后,刚刚更新数据一瞬间又消失了???
- C#窗体如何实现datagridview中字体闪烁
取消 和 确定 按钮 拖拉 2个就行了
文本替换 就是 窗体之间传值问题
new 弹出窗体的时候 把 textbox1 传过来就行了
来,咱们一步步分析啊~!
textbox1里有一段文本 To: oo By: xx Content: ...
那就是页面要有一个文本框是吧,里面有字是吧!
然后我双击textbox1,就会弹出一个大的文本框上面有 取消 和 确定 按钮,
文本框可以直接弹出吗,应该是一个层或页面吧,上面有文本框,有取消和确定按钮是吧~!
可以用JS获取textbox1的值,在给倒你弹出层上的textbox的value ,这没什么问题吧!
用正则匹配你说要高亮的那几个字符串,加上样式,这也没什么问题吧!
编辑后在把你弹出层上的textbox的value 给回textbox1里这也没什么问题吧!说实话,你的问题我一点也没明白~!
不过我是说在WinForm里哦,就是1L说的那种
然后你点击textbox1的时候把那个实例化那个form并把文本传过去,就可以了如form1 f = new form1 ("文本");
DialogResult result = f.ShowDialog()
文本的值你随便找个方法传过来,高亮的意思就是加个颜色对吧~
test.html
关闭按钮:window.close();
确定按钮:window.opener.document.getElementById("文本框ID").value="新值";
創建一個輔助類
吧你雙擊出來的文本內容傳到輔助類里
textbox1 直接可以到那個輔助類里去取值因為是菜鳥..希望能給樓主提供點思路...不對勿噴........
//你所说的textbox1的页面
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace TestShow
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
//写一个窗体的有参构造
public Form2(string str)
{
InitializeComponent();
textBox1.Text = str;
}
//textbox1鼠标双击事件
private void textBox1_MouseDoubleClick(object sender, MouseEventArgs e)
{
Form1 fr1 = new Form1(textBox1.Text);
fr1.Show();
this.Visible = false;
}
}
}//=============================================
//你所说的有个大文本框的窗体
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;namespace TestShow
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//一个窗体有参构造
public Form1(string str)
{
InitializeComponent();
this.bigTextBox.Text = str;//bigTextBox为大文本框
}
//确定按钮事件
private void btnOk_Click(object sender, EventArgs e)
{
Form2 fr2 = new Form2(bigTextBox.Text);//将大文本框的值传给小文本框的页面
fr2.Visible = true;
this.Visible = false;
}
//取消按钮
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
//或者
//this.Visible = false;
}
}
}
//有大文本框的那个窗体修改一下
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;namespace TestShow
{
public partial class Form1 : Form
{
string temp="";//加一个临时变量,用于存储传过来的值
public Form1()
{
InitializeComponent();
}
//一个窗体有参构造
public Form1(string str)
{
InitializeComponent();
this.bigTextBox.Text = str;//bigTextBox为大文本框
temp=str;//把form2的初始值存到临时变量中
}
//确定按钮事件
private void btnOk_Click(object sender, EventArgs e)
{
Form2 fr2 = new Form2(bigTextBox.Text);//将大文本框的值传给小文本框的页面
fr2.Visible = true;
this.Visible = false;
}
//取消事件
private void btnCancel_Click(object sender, EventArgs e)
{
Form2 fr2 = new Form2(temp);//如果取消就把原来值的传回去
fr2.Visible = true;
this.Visible = false;
}
}
}
怎么知道传回来的值是赋到哪个textbox里呢?
传回来根据textbox名字判断
假如是 textbox2 弹出的大文本框,那么改完之后怎么把值赋给textbox2
textbox1 弹出的 改完后赋给textbox1
public partial class Form1 : Form
{
private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.Show(this);
}
} public partial class Form2 : Form
{
private void button1_Click(object sender, EventArgs e)
{
Form1 frm1 = (Form1)this.Owner;
((TextBox)frm1.Controls["textBox1"]).Text = this.textBox2.Text;
this.Close();
}
} Font f=new Font("Verdana", 8F, FontStyle.Italic, GraphicsUnit.Point);
string str="";
if (richTextBox1.Find(str)>0)
{
int pos=richTextBox1.Find(str);
richTextBox1.SelectionStart=pos;
richTextBox1.SelectionLength=str.Length;
richTextBox1.SelectionFont=f;
richTextBox1.SelectionColor=Color.Red;
}