树视图与外部文本框 [英] Treeview with textboxes outside

查看:111
本文介绍了树视图与外部文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我工作的树状。结果
除了树视图有3个文本框。结果
点击树状的节点需要启用文本框。结果
那过程。


  1. 如果我写的第一文本框中的文本应在TreeView的第一个节点的子节点显示

  2. 点击该节点第二个文本框应该启用。

  3. 这应该是同为3文本框应启用。

  4. 什么都我在写的文本框,并在节点复制的文本应保存在数据库中。


解决方案

我假设你的树状节点是present。结果
如果不是我的code给你一些错误。结果
所有三个文本框OnTextChanged事件必须引用 textBox_TextChanged 方法。

响应1/2/3:

 公共部分Form1类:表格
{
    树节点首先,child01,child02,child03;    公共Form1中()
    {
        的InitializeComponent();
        treeView1.ExpandAll();        第一= treeView1.Nodes [0];
        child01 = first.Nodes [0];
        child02 = first.Nodes [1];
        child03 = first.Nodes [2];
    }    私人无效textBox_TextChanged(对象发件人,EventArgs的发送)
    {
        如果(发送者== textBox1中)child01.Text = textBox1.Text;
        否则,如果(发件人== TextBox2中)child02.Text = textBox2.Text;
        否则,如果(发件人== textBox3)child03.Text = textBox3.Text;
        //保存文本数据库这里
    }    私人无效treeView1_NodeMouseClick(对象发件人,TreeNodeMouseClickEventArgs E)
    {
        textBox1.Enabled =(e.Node == child01);
        textBox2.Enabled =(e.Node == child02);
        textBox3.Enabled =(e.Node == child03);
    }
}

Currently I'm working on treeview.
Apart from treeview there are 3 textboxes.
By clicking nodes of treeview I need to enable textboxes.
Procedure of that is.

  1. If I write text in first text box that should display in treeview's first node's child node
  2. By clicking that node second text box should be enabled.
  3. That should be same for 3 textboxes that should be enabled.
  4. What ever the text that I wrote in textboxes and copied in the node should be saved in database.

解决方案

I assume that in your treeview nodes are present.
If not my code gives you some error.
All three textboxes OnTextChanged event must reference textBox_TextChanged method.

RESPONSE 1/2/3:

public partial class Form1 : Form
{
    TreeNode first, child01, child02, child03;

    public Form1()
    {
        InitializeComponent();
        treeView1.ExpandAll();

        first = treeView1.Nodes[0];
        child01 = first.Nodes[0];
        child02 = first.Nodes[1];
        child03 = first.Nodes[2];
    }

    private void textBox_TextChanged(object sender, EventArgs e)
    {
        if (sender == textBox1) child01.Text = textBox1.Text;
        else if (sender == textBox2) child02.Text = textBox2.Text;
        else if (sender == textBox3) child03.Text = textBox3.Text;
        // Save text in database here
    }

    private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
    {
        textBox1.Enabled = (e.Node == child01);
        textBox2.Enabled = (e.Node == child02);
        textBox3.Enabled = (e.Node == child03);
    }
}

这篇关于树视图与外部文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆