|
Hi All
I'm sorry if this is a dumb question, I'm a newbie to .NET programming...
I have a windows app with a treeview control displaying a section of the file system (folders and files).
What I would like to do is drag and drop files from the desktop for example onto a treeview node to copy that file into the relevant folder, just like with windows explorer. I have found plenty of articles on drag and drop between treeviews and list boxes and databases etc, but nothing for files.
Is there anybody out there who can help me???
Thanks in advance...
|
|
|
|
|
|
Thanks for this, but its not quite what I'm looking for, and I'm starting to think it may not be possible.
I want to drag files from outside my app into the treeview within my app. I may well be wrong, but it appears that drag and drop can only be performed between controls in the same application.
Just for background info, the application is project managing software. Projects can be created, tracked etc. The app creates a set of folders on a network drive under the projects unique ID. The TreeView shows the files and folders within the projects own file structure. I want users to be able to drag items from their local machine or network drives into the relevant folders within the app's projects folder tree to keep everything centralised...
Any idea's would be greatly appreciated.
Thank you...
|
|
|
|
|
My appologies, I took presumption that you were merely after same application drag and drop functionality. In short, it is possible, as I use this functionality on some code I wrote 3 years back. Unfortunately, this code is at home (and I'm currently in a training course).
However I did find this, which should give you a step in the right direction:
http://www.dotnetcurry.com/ShowArticle.aspx?ID=192&AspxAutoDetectCookieSupport=1[^]
|
|
|
|
|
This works for me
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
treeView1.AllowDrop = true;
}
private void treeView1_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files)
{
}
}
}
private void treeView1_DragOver(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.None;
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Copy;
}
}
}
[edit] I've read that this will sometimes not work under Vista (not got Vista here to try it) when debugging from the IDE. Build the exe and run independantly and it should be OK. [/edit]
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)
modified on Wednesday, November 5, 2008 7:36 AM
|
|
|
|
|
Thats mint. Just what I needed.
Thanks to both of you.
|
|
|
|
|
I want to communicate between two forms one is written by me and other is already written by someone but i have executable file only.
I want to extract data from the Textbox of other form not developed by me
My form is in C# 2.0 and the other is where as i think is written VB6.0. I will appriciate if anyone can provide me an example
thanks
|
|
|
|
|
|
Sorry but i am not able to do it.
Can i have an example of getting text from another application form running as separate process
If so please help me and I'll be very thankful to you if you provide me a C# 2003/2005 project
I will be waiting for your reply
|
|
|
|
|
I can't do it for you but I have given you enough keywords for you to search and explore. There are several articles at codeproject that show how to do it.
|
|
|
|
|
So you are voting one because I didn't do your work? This will not encourage any member to help you
|
|
|
|
|
I am sorry i hurt you but i was not intended to do so
I just vote the material is not helping but i appreciate your consideration for intime and first reply
Thanks a lot
Again i will say sorry
|
|
|
|
|
I current can crop certain part of the colour image using
Rectangle rect = new Rectangle(btmX, btmY, rectWidth, rectHeight);
//reading image to graphics
Graphics g = Graphics.FromImage(selectedImg);
//drawing with red pen width 1
Pen pen = new Pen(Color.Red, 1);
//e.Graphics.DrawRectangle(pen, rect);
//drawing the rectangle here
g.DrawRectangle(pen, rect);
picBoxOpen.Image = selectedImg;
//g.Dispose();
but once i crop a grayscaled Image it gave me this problem
+ $exception {"A Graphics object cannot be created from an image that has an indexed pixel format."} System.Exception
I'm kind of new in this image processing area can any kind souls help me out with this please :P thanks
|
|
|
|
|
Cropping an image is one thing... but why are you drawing a red rectangle on the image? From what I can see, the usage of a color outside of the image's pallette range is what is causing your current error, but I certainly cannot see from first glance why you are even using it.
|
|
|
|
|
Oh, cause my program I want to enable a selection for users, using mouse down and mouse up event for users to select the part they wanan crop and a rectangle will be drawn once they selected the part to crop
|
|
|
|
|
What the meaning os this code:
string string1;
string string2=string1.TrimEnd( new char[0]);
Thanks
|
|
|
|
|
It trims the null(s) off the end of string1.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
|
The expression new char[0] creates a new array of characters with the length zero.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Ashfield wrote: It trims the null(s) off the end of string1.
Not really. It trims white space characters off the end of the string.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
If you have something like this:
char[] trim = { 'o', 'a' };
textBox1.Text = "Hellooooo".TrimEnd(trim[0]);
TrimEnd will remove all 'o's from the end of your string, if you try to use TrimEnd like this:
textBox1.Text = "Hellooooo ".TrimEnd(new char[0]);
char[0] means whitespace and TrimEnd will remove all whitespaces from the end.
When you're alone in the Dark, Fear will protect you...
|
|
|
|
|
If you call the TrimEnd method with an empty array, it will remove all white space characters from the end of the string.
This is a special case, that is not covered in the documentation. I have sent a message to Microsoft about it.
Update:
I got a reply from Microsoft, and they have updated the documentation.
Despite everything, the person most likely to be fooling you next is yourself.
modified on Thursday, November 6, 2008 6:33 AM
|
|
|
|
|
I have a checkbox field in the datagridview control as column 1 called "Select" as the name of the column.
When the user selects this checkbox for any row, I would like to run some code and based on an if statement to set this checkbox to false.
I am running this as follows but the checkbox is set to true i.e checked and can not change it to unchecked.
What am I doing wrong please?
private void dgv_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex >= 0)
{
if (dgv.Columns[e.ColumnIndex].Name.ToLower() == "select")
{
int intSecuritySetting = Convert.ToInt32(dgv.Rows[e.RowIndex].Cells["SecuritySetting"].Value);
if (intSecuritySetting == 0)
{
//Make sure the security check is set to false...
dgv.Rows[e.RowIndex].Cells["Select"].Value = CheckState.Unchecked;
}
}
}
}
modified on Wednesday, November 5, 2008 4:06 AM
|
|
|
|
|
Hi arkiboys,
int intSecuritySetting = Convert.ToInt32(dgv.Rows[e.RowIndex].Cells["SecuritySetting"].Value);
.Cells should be the int value instead of string
example:
int intSecuritySetting = Convert.ToInt32(dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value
or
int intSecuritySetting = Convert.ToInt32(dgv.Rows[e.RowIndex].Cells[1].Value
hope this help
|
|
|
|
|
The value property gets updated after the cell click event and cellcontentclick event(atleast in the sample code I had written). Hence even if I change the checked state, it will again get changed. I wrote the same code in cellvaluechanged event and it works. Hope this helps.
|
|
|
|