|
Hi EveryBody,
How to Drag and Drop Treeview Item into listview? Please help me out..
I have one parent node and two child nodes. when I drag a Parent Node, included child nodes are also to be dragged.
And all of them to be placed in listview row (3 columns).
Please help me out with a sample example. Itz very urgent for me
|
|
|
|
|
|
Udayaraju wrote: Itz very urgent for me
... but not urgent for us. I saw your post hours ago but ignored it because of this. Bumping your post will not get you any further.
I won't give you the code but I'll give you the theory so you can code it yourself. If you get stuck with a specific part of your code, post it and we'll have a look.
What you want is a very simple 3 step process.
In the treeview's mousedown event , get the node at the mouse point. Set the selectednode to be that node If it's not null and is a 'Parent' node, call the treeview's DoDragDrop method.
In the listview's dragover event, set the effect property of the event arguments to copy.
In the litview's DragDrop event, convert the data to a treenode (would be a good idea to null check here too) then convert it and it's nodes (children) to a listviewitem with listviewsubitems and add to your listview.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hi,
Thanq for ur Suggestion But i tried inthes way..can you corect the problem here.
See the below code. Here I have a Problem. Treeview has already one root node and twochild nodes with it.
They have to be dragged and dropped in listview.
The main Problem is wen I drag an item..the Itemdrag event is not fired.?? Please try to resolve it.
private void tvwSalesProducts_ItemDrag(object sender, ItemDragEventArgs e)
{
tvwSalesProducts.DoDragDrop(e.Item, DragDropEffects.Copy | DragDropEffects.Move);
}
private void lstMultiProItems_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Copy | DragDropEffects.Move;
}
private void lstMultiProItems_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false))
{
string[] Items = new string[5];
TreeNode SourceNode;
SourceNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
Items[0] = Convert.ToString(SourceNode.Tag);
Items[1] = SourceNode.Text.ToString();
Items[2] = SourceNode.FirstNode.Text.ToString();
Items[3] = SourceNode.LastNode.Text.ToString();
lstMultiProItems.Items.Clear();
lstMultiProItems.Columns.Add("ID", 100, HorizontalAlignment.Left);
lstMultiProItems.Columns.Add("Product Name", 100, HorizontalAlignment.Left);
lstMultiProItems.Columns.Add("Selling Price", 100, HorizontalAlignment.Left);
lstMultiProItems.Columns.Add("Conversion", 100, HorizontalAlignment.Left);
ListViewItem Item1 = new ListViewItem(Items);
lstMultiProItems.Items.Add(Item1);
lstMultiProItems.AllowColumnReorder = false;
lstMultiProItems.FullRowSelect = true;
}
}
|
|
|
|
|
Check out the working code below and compare - you should be able to figure it out from this.
void treeView1_ItemDrag(object sender, ItemDragEventArgs e)
{
TreeNode nodeData = (TreeNode)e.Item;
treeView1.SelectedNode = nodeData;
if ((string)nodeData.Tag == "Parent" && nodeData.Nodes.Count == 2)
treeView1.DoDragDrop(nodeData, DragDropEffects.Copy);
}
void listView1_DragOver(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.None;
TreeNode nodeData = (TreeNode)e.Data.GetData(typeof(TreeNode));
if (nodeData != null && (string)nodeData.Tag == "Parent" && nodeData.Nodes.Count == 2)
e.Effect = DragDropEffects.Copy;
}
void listView1_DragDrop(object sender, DragEventArgs e)
{
TreeNode nodeData = (TreeNode)e.Data.GetData(typeof(TreeNode));
if (nodeData != null && (string)nodeData.Tag == "Parent" && nodeData.Nodes.Count == 2)
{
ListViewItem newItem = new ListViewItem(nodeData.Text);
foreach (TreeNode childNode in nodeData.Nodes)
{
ListViewItem.ListViewSubItem newSub = new ListViewItem.ListViewSubItem();
newSub.Text = childNode.Text;
newItem.SubItems.Add(newSub);
}
listView1.Items.Add(newItem);
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Thanq very mUch Dave..... these may help me a Lot.
I wil go through It and cum with u New errors..
Jus Kidding
|
|
|
|
|
Guys Please Help me out,
I have added the event handlers from front end design. but still the event is not fired.
Can u please tel me wther the code is correct or not
|
|
|
|
|
Hello,
I have a below issue with the windows service.
I have a method as below
private void OnElapsedTime(object source, ElapsedEventArgs e)
{
log.Info("OnElapsedTime");
BillPay.ProcessOrder();
}
I have a timer set for 1 mins in OnStart method
protected override void OnStart(string[] args)
{
//ad 1: handle Elapsed event
timer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
//ad 2: set interval to 1 minute (= 60,000 milliseconds)
timer.Interval = 60000 ;
//ad 3: enabling the timer
timer.Enabled = true;
}
The problem:
If my ProcessOrder() method which process all orders do not get completed in 1 mins I see unexpected results in the database with duplicate entry. I suspect the method ProcessOrder() get called again onTimeElapsed, I have commit and rollback statements too. But does not help.
Please suggest as how can I resolve this issue.
Regards,
Pavas
|
|
|
|
|
Stop the timer while you call the method, so that it does not start the event handler in another thread.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
So when it will again start?
Regards,
Pavas
|
|
|
|
|
I believe, timer will start right after the method call is over..let me try this
Regards,
Pavas
|
|
|
|
|
It will start when you turn the timer on again.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Put your work into a thread, and fire off the thread each time the timer ticks. You can even prevent multiple threads from kicking off with appropriate code in the tick handler.
Personally, I wouldn't use a Timer object because it's the lowest priority message in Windows, and in a busy system, there's no guarantee the message will even be handled. Instead, I use a BackgroundWorker object for timers because they can be easily aborted. Sure, it's more code (go forbid a programmer should have to actually write some code), but it's much more reliable and controllable.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: Personally, I wouldn't use a Timer object because it's the lowest priority message in Windows, and in a busy system, there's no guarantee the message will even be handled. Instead, I use a BackgroundWorker
That is true for a Windows Forms timer running on the UI thread. But the OP is writing a service, so he's probably using System.Threading.Timer or System.Timers.Timer . AFAIK, both of them use the ThreadPool, and so does BackgroundWorker
|
|
|
|
|
i can do parent dynamic gridview --> child dynamic gridview but ive a problem at the interface of triple dynamic gridviews how do i do for that ??
|
|
|
|
|
I prefer to 'Hungarian Notation' than 'PascalCase' to named controls.
e.g.
I like use btnOk, btnCancel, txtName, txtAge
but not okButton, cancelButton, nameTextBox, ageTextBox.
which one do you like? and why?
Glad to discuss with you and best wishes.
|
|
|
|
|
The former, but only with controls. When I need to store the user's name in a string, it's always userName, never strUserName.
Cheers,
Vıkram.
I've never ever worked anywhere where there has not been someone who given the choice I would not work with again. It's a job, you do your work, put up with the people you don't like, accept there are probably people there that don't like you a lot, and look forward to the weekends.
- Josh Gray.
|
|
|
|
|
Yes, I'll named control like txtUsername, and named variable userName.
But now, I have to named control like userNameTextBox... but I don't like...
Glad to discuss with you and best wishes.
|
|
|
|
|
The actual class: MyTextBox
The class instance: myTextBox
Its properties and events: Text ... TextChanged
Why, to follow the convention that is used almost everywhere, and so I can see instantly if I'm working with an instance or a static
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I use buttonOK , checkboxCheckMe , etc. That way, all controls of the same type are grouped in the same place in intellisense.
You could take it a step further and maybe use ctlButtonOK , and ctlCheckboxCheckMe , and that would put *all* of the controls in one single group in intellisense, yet still separate the controls by type within the group.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: all controls of the same type are grouped in the same place in intellisense.
Agree with you, especially for the same type control.
Glad to discuss with you and best wishes.
|
|
|
|
|
I want to get a device state(enable or disable)?
If i have a device name, how to get it?
Thank a lot.
|
|
|
|
|
What kind of device are you working with?
Keep It Simple Stupid! (KISS)
|
|
|
|
|
Try using WMI to get the device.
Glad to discuss with you and best wishes.
|
|
|
|
|
getting the row index in c#
|
|
|
|
|