u1jd
asked on
Treeview problem (Very Hard)
I have a drag and drop system from a treeview to a rich text box, which when you select and drag a node from the tree it places the tag value into the rich text box, however i want to just click on a node on the tree and click a button which will assign the value of its tag to a variable named puretext, this is a global variable which i am passing to another class file.
The code below is the drag and drop code, when you drag it assigns the tag of the selected node to PureText, however i dont want to have to drag the node into the text just click on it then press a button to load the other class and the tag value of the node will be in the global variable PureText.
Thanks.
If you need more code or clarrification just ask, please help asap
// ------------------------ Drag and Drop System -------------------------- ---------- ---------- ------- //
private void treeView1_ItemDrag(object sender, System.Windows.Forms.ItemD ragEventAr gs e)
{
DoDragDrop(e.Item, DragDropEffects.Copy | DragDropEffects.Move);
}
protected void richTextBox1_TextChanged (object sender, System.EventArgs e)
{
if(richTextBox1.SelectedTe xt=="")
{
menuItem_cut.Enabled=true;
menuItem_copy.Enabled=true ;
menuItem_del.Enabled=true;
}
else
{
menuItem_cut.Enabled=false ;
menuItem_copy.Enabled=fals e;
menuItem_del.Enabled=false ;
}
}
private void richTextBox1_DragEnter(obj ect sender, System.Windows.Forms.DragE ventArgs e)
{
if (e.Data.GetDataPresent(typ eof(TreeNo de)))
((DragEventArgs)e).Effect = DragDropEffects.Copy;
else
((DragEventArgs)e).Effect = DragDropEffects.None;
}
private void richTextBox1_DragDrop(obje ct sender, System.Windows.Forms.DragE ventArgs e)
{
TreeNode
MyNode=(TreeNode)e.Data.Ge tData("Sys tem.Window s.Forms.Tr eeNode");
PureText = MyNode.Tag.ToString();
int i;
String s;
i = richTextBox1.SelectionStar t;
s = richTextBox1.Text.Substrin g(i);
richTextBox1.Text = richTextBox1.Text.Substrin g(0,i);
richTextBox1.Text = richTextBox1.Text + PureText;
richTextBox1.Text = richTextBox1.Text + s;
}
Load method for the class i want to load when i select a node from the tree then click a button
private void edit_Click(object sender, System.EventArgs e)
{
editbib latexide = new editbib();
latexide.ShowDialog(this);
}
The code below is the drag and drop code, when you drag it assigns the tag of the selected node to PureText, however i dont want to have to drag the node into the text just click on it then press a button to load the other class and the tag value of the node will be in the global variable PureText.
Thanks.
If you need more code or clarrification just ask, please help asap
// ------------------------ Drag and Drop System --------------------------
private void treeView1_ItemDrag(object sender, System.Windows.Forms.ItemD
{
DoDragDrop(e.Item, DragDropEffects.Copy | DragDropEffects.Move);
}
protected void richTextBox1_TextChanged (object sender, System.EventArgs e)
{
if(richTextBox1.SelectedTe
{
menuItem_cut.Enabled=true;
menuItem_copy.Enabled=true
menuItem_del.Enabled=true;
}
else
{
menuItem_cut.Enabled=false
menuItem_copy.Enabled=fals
menuItem_del.Enabled=false
}
}
private void richTextBox1_DragEnter(obj
{
if (e.Data.GetDataPresent(typ
((DragEventArgs)e).Effect = DragDropEffects.Copy;
else
((DragEventArgs)e).Effect = DragDropEffects.None;
}
private void richTextBox1_DragDrop(obje
{
TreeNode
MyNode=(TreeNode)e.Data.Ge
PureText = MyNode.Tag.ToString();
int i;
String s;
i = richTextBox1.SelectionStar
s = richTextBox1.Text.Substrin
richTextBox1.Text = richTextBox1.Text.Substrin
richTextBox1.Text = richTextBox1.Text + PureText;
richTextBox1.Text = richTextBox1.Text + s;
}
Load method for the class i want to load when i select a node from the tree then click a button
private void edit_Click(object sender, System.EventArgs e)
{
editbib latexide = new editbib();
latexide.ShowDialog(this);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Answer just needed
if( treeView1.SelectedNode != null )
PureText = treeView1.SelectedNode.Tag
but still it is brilliant , thankyou so much, points are all yours