开发者

Treeview with textboxes outside

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 n开发者_StackOverflow中文版ode'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);
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜