|
Hi,
AFAIK you can use wildcards in GetFiles, the same you can in a DOS window,
or the Explorer's search pane, but nothing more fancy.
So you end up with two choices:
- do GetFiles("*.doc") and skip the files you dont like; (you would need
Path.GetFileName to extract the short file name again);
- create a loop with myChar going from 'a' to 'z' and do GetFiles(""+myChar+"*.doc"),
or alternatively construct a constant string that holds acceptable starting letters
and do a foreach myChar on it.
|
|
|
|
|
Thanks! Thats kinda what I thought, but figured I would ask to see....
|
|
|
|
|
Hi,
I'm implementing a drag object operation with panels.
The code i'm using for that is:
<br />
private void panel_MouseDown(object sender, MouseEventArgs e)<br />
{<br />
Panel region = (Panel)sender;<br />
<br />
drag = true;<br />
panelBeingMoved = region;<br />
<br />
x = e.X;<br />
y = e.Y;<br />
}<br />
<br />
private void panel_MouseUp(object sender, MouseEventArgs e)<br />
{<br />
drag = false;<br />
panelBeingMoved = null;<br />
}<br />
<br />
private void panel_MouseMove(object sender, MouseEventArgs e)<br />
{<br />
if (drag) {<br />
panelBeingMoved.Left += e.X + x;<br />
panelBeingMoved.Top += e.Y -y;<br />
<br />
x = e.X;<br />
y = e.Y;<br />
}<br />
}<br />
The problem is that the panel behaves in a very strange way. Instead of coming togheter smoothly with the mouse it is always jumping around with some pattern that i can justify.
Is there any simple explanation for this bahaviour?
What am i missing?
Thx,
Nuno
|
|
|
|
|
Hi
this is a different , method to move Control
hope it will help ,
Class1.cs
<br />
using System;<br />
using System.Runtime.InteropServices;<br />
<br />
public class Class1<br />
{<br />
public static int HTCAPTION = 2;<br />
public static int WM_NCLBUTTONDOWN = 0xA1;<br />
[DllImport("user32.dll")] <br />
public static extern int ReleaseCapture () ;<br />
[DllImport("user32.dll")] <br />
public static extern int SendMessage (IntPtr hWnd, int wMsg , int wParam, ref int lParam ) ;<br />
public Class1()<br />
{<br />
}<br />
}<br />
Example :
private void panel1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
<br />
int reflParam = 0;<br />
Class1.ReleaseCapture ();<br />
Class1.SendMessage (panel1.Handle , Class1.WM_NCLBUTTONDOWN , Class1.HTCAPTION , ref reflParam );<br />
}<br />
P.S
JUST TRY IT ... it's work like charming even if it look dos not
Have a good day ....
I know nothing , I know nothing
|
|
|
|
|
Hi,
Yes, this solution worka like charms. The only problem is that i don't understand what i am doing.
How can i get reference documentation for this? How can i know what more can i do with this?
I would love to be able to resize for example. Like you do when you choose a transform operation in Photoshop for example.
Thx,
Nuno
|
|
|
|
|
hi ( and thank you for testing my code )
no worries , if you don't understand it ...
cause my code was C++ and Win32 API , more than C# code
you can find many of this stuff ,
by searching in ( MSDN , Win32 API , C++ code .... etc )
have a good day
I know nothing , I know nothing
|
|
|
|
|
Hi guys,
I need some help please, I have a treeview and for each node I want to show tooltip data; this data is stored in a table and I don't think querying the table everytime the mouse is moved is a good idea. I was wondering if anybody knew a different way of showing the tooltip with database table data.
Please help!!!
sasa
|
|
|
|
|
hi
when you building your treeview
try to store your tooltip in ArrayList
then query the tooltip from this ArrayList
Have a good day ....
I know nothing , I know nothing
|
|
|
|
|
Thank you for your response. I have never used an arraylist before I googled and found some information but none shows on how to query an arraylist. Could you please give me an example.
sasa
|
|
|
|
|
Query the table just once when the treeview is loaded and store it in a datatable. After that display the data when the mouse is moved.
|
|
|
|
|
Thank you for your response. I believe I know how to do this. Either way once I have the datatable in order to get the tooltip data for that particular node, do I use datarow.select based on the ID of the data that I want to show?
Please advice
sasa
|
|
|
|
|
Thanks buddy. I got it to work with your suggestion.
sasa
|
|
|
|
|
You are welcome
|
|
|
|
|
I faced a problem when connting wiht Oracle9i. Plz somebody give me the instruction.
How can i get connected with Oracle9i.
sarwarmdgolam
|
|
|
|
|
What kind of problem are you facing?
|
|
|
|
|
OK, this is probably the C++ programmer in me still trying to break through the C# fog (so far it's been quite a pleasant learning curve though).
I woud like to "give names" to the values that my functions return. In my C++ days I would have used something like
#define OK 0<br />
#define ERR_PORT_NOT_OPEN -100<br />
#define ERR_NO_CARRIER -101
etc.
A function can then return ERR_PORT_NOT_OPEN if the port is not open as opposed to a meaningless int value of -100.
So I thought I'd go with enumerated types in C# and while it works I do feel that it could be a little more elegant.
I wrote a class called Defines with an enumerated type resembling this:
public enum ERR<br />
{<br />
OK = 0,<br />
PORT_NOT_OPEN = -100,<br />
NO_CARRIER = -101,<br />
}
so now a function can return Defines.ERR.PORT_NOT_OPEN as opposed to -100.
My gripe with this approach is that I'm constantly having to typecast this enumerated type to (int) . In other words the function has to return (int)Defines.ERR.PORT_NOT_OPEN and if I want to compare the outcome of a function with a switch for instance I have to do something like:
switch (myFunc())<br />
{<br />
case (int)Defines.ERR.PORT_NOT_OPEN:<br />
...<br />
break;<br />
case (int)Defines.ERR.NO_CARRIER:<br />
...<br />
break;<br />
}
I don't want to change the return type of the functions from int to Defines.ERR because I still have to use native functions which return int values (corresponding to the #define values of course).
So what do you guys do to achieve what I'm trying to?
|
|
|
|
|
Dewald wrote: #define OK 0
#define ERR_PORT_NOT_OPEN -100
#define ERR_NO_CARRIER -101
static class ErrCodes
{
const int ERR_PORT_NOT_OPEN = -100;
const int ERR_NO_CARRIER -101;
...
} "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Thanks dnh, this looks great. Do you have any idea what the implications on memory usage is of this approach? The whole reason why, in C++ #defines were used is to save the memory that would have been allocated had the defines been constants or variables.
|
|
|
|
|
Dewald wrote: I don't want to change the return type of the functions from int to Defines.ERR
This is your problem. As long as you want to use an int value, the coding will be somewhat painful.
If you want to avoid writing (int) here and there, you can create constants instead of using an enum. That would work pretty much as using #define in C++.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks Guffa,
The reason I steered away from constants is because that would take up memory. I know memory conservation is probably not a big deal nowadays but I still tend to cringe when unneccesary memory is being taken up.
|
|
|
|
|
Constants are only stored once, like a static. If you have a constant defined in a class and multiple objects created from that class, the runtime won't create multiple copies of the same constants. There will only be one copy of the constants in memory usable by every instance of the class.
In a world where a machine comes with 128M minumum, a few constants, or a few hundred constants, are not going to break the bank. An int32 constant is just 4 bytes. Even if you have 1,000 constants in a class and a thousand objects created from that class, you're still only using 4K for the constants.
|
|
|
|
|
Dave Kreskowiak wrote: Constants are only stored once, like a static.
That is only true for reference type constants. Value type constants, like in this case, isn't stored anywhere. They are inlined in the code that uses it, producing the same code as if a literal value had been used.
Dave Kreskowiak wrote: Even if you have 1,000 constants in a class and a thousand objects created from that class, you're still only using 4K for the constants.
Nope. Zero bytes.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks guys,
That's very interesting and really god to know.
|
|
|
|
|
Dewald wrote:
The reason I steered away from constants is because that would take up memory.
No, they don't. Constants are inlined at compile time, so they don't take up more memory than literal values.
I prefer using an enum rather than constants in a case like this, as an enum says a lot more about what a method returns than an int does. When a method returns an enum value, you don't have to read a lot of documentation to find out what constants to use to compare the return value with.
If you want the int value you can easily cast the enum to int, and use that with any existing code that requires an int.
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa wrote: I prefer using an enum rather than constants in a case like this, as an enum says a lot more about what a method returns than an int does. When a method returns an enum value, you don't have to read a lot of documentation to find out what constants to use to compare the return value with.
If you want the int value you can easily cast the enum to int, and use that with any existing code that requires an int.
Agreed, he said it's native method (so he can't quite change the method return value type itself), but wrapper returning enum would do.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|