|
As no-one has answered your question, I'll have a go.
Take a look at Control.MousePosition and see if that helps you.
Good Luck.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks. I already have a look on Control.MousePosition.
I can get the mouse position but i can't drop it at the specific location.
All example that i found is:
1. Get the drag item detail and index when drag.
2. Get the mouse position when drop.
3. Base on mouse position, the application convert the mouse position to index. Every index represent a rectangle. Any point in the rectangle will use same index.
4. The item will insert at the rectangle represent by the index.
The function that i found all will draw or insert picture base on index and not actual mouse position. It need to pass in index and not mouse position. So, anyone have any suggestion?
Regards,
Pei Yang
|
|
|
|
|
Hello!
I'm trying to have a custom-sorter class to sort my objects.
I want my objects to always be in a certain order(not alphabetically).
In my Compare(object a, object b) method I check which objects they are and return 1 or -1 depending on which one I want to come first. How exactly does it work, do I return -1 if I want object a before object b in my collection? It doesn´t seem consistent to me, some values get sorted correctly and some don´t.
|
|
|
|
|
You probably should post your code and your test data.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
-1 if a less than b,
0 if a equal b,
1 if a greater than b.
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 wrote you a little sameple which might help.
I have 3 types of pet:
public class Dog { }
public class Cat { }
public class Rabbit { }
I dont want to order these alphabetically, I want to order them in order of my preference of them as pets. I like cats more than dogs, and dogs more than rabbits. I could write a comparer to always order a list of pets in my prefered order:
public class MyPetPreferenceComparer : IComparer
{
#region IComparer Members
public int Compare(object x, object y)
{
if (x.GetType() == y.GetType())
return 0;
if (x is Cat)
{
return -1;
}
if(x is Dog)
{
if (y is Rabbit)
return -1;
return 1;
}
if (x is Rabbit)
return 1;
return 0;
}
#endregion
}
Now the test code:
ArrayList list = new ArrayList();
list.Add(new Rabbit());
list.Add(new Cat());
list.Add(new Dog());
list.Add(new Cat());
list.Add(new Rabbit());
list.Add(new Dog());
list.Sort(new MyPetPreferenceComparer());
foreach (object obj in list)
{
Console.WriteLine(obj.GetType().Name);
}
Outputs:
Cat
Cat
Dog
Dog
Rabbit
Rabbit
One thing Id add - nowdays we tend to prefer the generic versions of these sorts of interface so try to use IComparer<T> in System.Collection.Generics
|
|
|
|
|
|
Hi,
an int comparer could just return the difference, as in:
public static int Compare(int a, int b) {return a-b;}
BTW: you MUST return zero when both objects are identical.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 9:02 AM
|
|
|
|
|
Hi All,,,
I Get A Data From a sql server2005 Veiw/table using Dataset And Data Adapter,,,
I Want A C# Code To Return All constraints and Foreign Key At This Veiw/table.
please help me about this code
thanks all;
|
|
|
|
|
Do not repost the same vague question.
|
|
|
|
|
using System;
public class class1
{
static void Main(string[]args)
{
try
{
string s1 = args[0];
string s2 = args[1];
int i1 = int.Parse(s1);
int i2 = int.Parse(s2);
int i3 = i1 + i2;
Console.WriteLine(i3);
}
catch (Indexoutofrange Exception)
{
Console.WriteLine(Exception.message);
}
Console.WriteLine("hello");
}
}
when iam running this program it is showing the following errors
1.the tpe or namespace name could not be found
2.system.exception does not contain a definition for message
|
|
|
|
|
C# is case sensitive.
replace following lines:
catch (IndexOutOfRangeException exception)
{
Console.WriteLine(exception.message);
}
Console.WriteLine("hello");
}
}
Calin
|
|
|
|
|
aratireddy wrote: 1.the tpe or namespace name could not be found
There is no class called Indexoutofrange . It should be IndexOutOfRangeException
aratireddy wrote: system.exception does not contain a definition for message
aratireddy wrote: catch (Indexoutofrange Exception)
Exception is a class name and you can't use it as a variable. Try
catch (IndexOutOfRangeException ex)
{
Console.WriteLine(ex.message);
}
|
|
|
|
|
You asked this same question 4 hours agao and got an answer. Why repost it?
|
|
|
|
|
my video file extension is wmv.and i want that water mark for the entire duration of time
|
|
|
|
|
It would be easier if you posted answers in their original thread, instead of starting a new post. The forum will be harder to read if the same questions are being repeated over and over again.
So, replies go here[^].
BTW, we're no take-away chinese, and ordering code usually doesn't work. Most of us are glad to help a collegue out, but the chances that someone is going to write the code for you are very slim.
I are troll
|
|
|
|
|
Hello,
i use this to get all files in directories :
<br />
string[] files = Directory.GetFileSystemEntries(@"C:\");<br />
int filecount = files.GetUpperBound(0) + 1;<br />
if (filecount != 0)<br />
{<br />
DirectoryInfo di = new DirectoryInfo(@"C:\");<br />
<br />
foreach (FileInfo file in di.GetFiles())<br />
{<br />
DateTime Now = DateTime.Now;<br />
string name = file.Name;
string fullName = file.FullName;
}<br />
i would get not all files, but a file with a specific name lake doc1.pdf, thank you verry mutch.
|
|
|
|
|
just test if (file.Name.Equals("doc1.pdf")) // replace 'doc1.pdf' with your variable
|
|
|
|
|
We can't get the file path directly?? beacause i need to got two file with the same name, for exemple get the files doc1.pdf and doc3.pdf, thank you verry mutch.
|
|
|
|
|
Hi,
Before anyone can give you an answer you do need to decide what your question actually is. You started by asking how to find one file and now that you have that answer you have changed the question.
In the code you posted you used the DirectoryInfo.GetFiles method. If you were to invest some time in reading the documentation for that method and it's overloads you would be able to answer either of your questions on your own.
Alan
|
|
|
|
|
Hi,
as usual it helps to read the documentation: there is an overload of GetFileSystemEntries that accepts a filter, where you can specify part of the filename, as if you were searching in Windows Explorer.
Hence try Directory.GetFileSystemEntries(@"C:\", "doc*.pdf")
BTW: files.GetUpperBound(0) + 1 is terrible, just use files.Length
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 9:02 AM
|
|
|
|
|
Hey All,
I am trying to write an add-in for MS Word 2007. This add-in in one of its contexts helps the user create a a template automatically. Whenever a new template is created, these templates have to be avaialable for the user . Now what would i want to do is to create an extra menu specifying the list of "My Comapny" folder which carries all the templates that have been dynamically generated. I would like to have this list as a part of the Templates list i view when i press : Office > New > Templates. I hope you have understood where i would like to see my Template folder.
Plaese Help
Thanks in advance
Teja
|
|
|
|
|
Hai all,
I m using asp.net
in my application having a gridview>Sometimes i may get huge datas.
So i want load when scrolling the grid,at the same time initially i want load first 10 rows
can any one help?
thanks.
modified on Monday, March 2, 2009 4:45 AM
|
|
|
|
|
Try to populate the grid in Scroll event handler based on the scroll value. Actually, you may use a separate scrollbar(set the Min and Max based on the items count) and hide the one from gridview.
Calin
modified on Monday, March 2, 2009 4:48 AM
|
|
|
|
|
Hi friend
can any body tell me how i can insert website link to the message box message.
WANTED wasim khan(Killed 50 Innocent Buggs, Distroyed 200 Exception, make 5 Project Hostage) any Compnay Hire him will pay 30,000. Best place where u can get him is Sorcim Technologies Murre Road RWP
|
|
|
|