|
You have to do the sorting yourself by associating a comparer with the tree nodes. You could also do this by not sorting at all and adding tree nodes in the correct order.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
yes, i think the best way is that you add the information to you ListView sorted, not to add them then acting the sort.
you have to propose a void refreshScreen() method for this that refreshes the ListView and imports the updated status.
so, clear your ListView and them add the sorted information.
|
|
|
|
|
im trying to get the dropped path for hrs but didnt get anything that can do, when i drag item from listview and drop to anywhere, i want the path of that place, any idea how?
thanks
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
|
no thats not i need, i want to extract the file to somewhere else in hdd in any folder, like Desktop, those articles dropping only in the app or ordering the rows, i want something like Rar, that we can drop the compressed selected files anywhere in hd
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
i just know that this is not an impossible one (who doesn't? ). try to catch the answer and post your results to this post and learn us, too.
thanks
|
|
|
|
|
yes only if i get the solution xD i'm searching on this around one and half day but didnt find anything yet
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I read with great interest the article on Building a Generic Range Class[^] (and this second article[^] on the same subject).
I learned more thinking about and designing objects like that than all the dogs-are-animals-porche-is-a-car-has-an-engine books on OOA/OOD put together.
Does anyone know of any other Classes/articles on similar concepts I can study/incorporate into my programs? I'm looking for tool-box type classes that would be used in virtually any application. I'm more interested in middle-tier classes that work with general programming constructs rather than classes that help with GUI's and databases and such.
I hope my question makes sense.
|
|
|
|
|
Like this? http://www.codeplex.com/NGenerics
|
|
|
|
|
I want to insert code snippet for Console.WriteLine().
I type the characters cw and pressing ENTER or TAB. But nothing is happening.
When i type the characters cw intellisense shows me that this is code snippet for Console.WriteLine(), but either by pressing TAB or ENTER i can only see cw written.
Yes, i can explicitly invoke the "insert snippet" menu and select my snippet. But i want to insert snippet quickly during coding without invoking menu. Please tell me how to do so ?
Imtiaz
|
|
|
|
|
After typing "cw", hit tab two times.
|
|
|
|
|
Excellent, like the original poster I'd never understood how to do that. It's so easy when you know how!
Alan.
|
|
|
|
|
Yes, it's very easy. The most used one by me is "prop" for creating a property structure.
|
|
|
|
|
What about this use of generic base class und generic polymorphism ?
I found on the internet some Articles wich deal with generic base class and polymorphism but not in the following way. I know its not possible at the momenten but it should, i think.
Lets say we have class declarations like this
public class Range<T> {
public T Start { get; set; }
public T End { get; set; }
}
public class IntRange : Range<Int32> { }
public class DoubleRange : Range<Double> { }
public class DateTimeRange : Range<DateTime> { }
then we could use it in this way
Range<> range = new Range<float>();
range = new IntRange();
range = new DoubleRange();</float>
and so far the T contrain is naked then the compiler should assume the Property are from Type Object.
range = new IntRange();
object obj = range.Start;
int obj = range.Start;
int obj = (int) range.Start;
or the T contrain is limited to a inheritance of ValueType.
public class Range<T> where T : ValueType {
public T Start { get; set; }
public T End { get; set; }
}
...
range = new IntRange();
int obj = range.Start;
So i think that should be possible, or what you think ?
|
|
|
|
|
Anything that puts us back in the world of essentially containers that are not type safe, is bad IMO. You may as well create a collection of arraylists, if you're going to cast them anyhow
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
No, its not possible. Range< int > and Range< float > are two completely seperate types. I went through the basic reasoning in ( http://www.codeproject.com/script/Forums/View.aspx?fid=1649&msg=2612653 ) that thread.
If you do want them to inherit from a common base then make it explicit: class Range< t > : BaseRange.
I think you might be a little confused when you inherit IntRange : Range< int > - you would only need to do this if you were adding extra int specific functionality.
Edit: Damn, need to remember to add spaces for < and >
modified on Saturday, June 28, 2008 11:31 PM
|
|
|
|
|
Mark Churchill wrote: No, its not possible.
that's right, its not possible, but it should be, in my opinion.
Mark Churchill wrote: Range< int > and Range< float > are two completely seperate types.
that's right as well, that's why IMO there should be a posibility to use generic classes as basis.
List<> list = new List<>(); By the way i forgot to declare the Range<T> class as abstract. Its just a base class and must
be inherited because we can not implement some methods, for example IsBetween(T value);
Range<> range = Range<>();
range.Start
range.End
range = new IntRange();
range.Start
range.End
range = new DoubleRange();
range.Start
range.End
Mark Churchill wrote: class Range< t > : BaseRange.
What would that bring?
The property Start and End would be ever from the type Object and can't take another type, except we override them with new.
|
|
|
|
|
I'm not sure where the percieved benefit of having a concrete IntRange deriving from a Range< T >. Generics are specialization, not inheritance. Sometimes covariance/contravariance (always forget which way those go) is appropriate, but it generally leads to breaking type safety. As generics are generally used to provide type safety then you would be defeating one of their main purposes.
I would suggest the correct way of implementing and using a generic Range class would be along the lines of:
class Range< T > where T : IComparable< T >
{
T Start;
T End;
bool IsBetween(T i) => Start.CompareTo(i) < 0 && End.CompareTo(i) > 0;
}
Then the usage is trivial. No need for an abstract generic class with concrete types.
|
|
|
|
|
yea, i didn't tought about that way thx
but what if, i have a class wich contain a range that can be a range of DateTime and a range of ULong.
In that case i must use the object type as basis
Class SomeClassName{
public object RangeProperty{get; set; }
public SomeClassName( object range ){
RangeProperty = range;
}
public DataTable SearchForDatabaseEntries(){
if( RangeProperty is Range<DateTime> ){
}
else if( RangeProperty is Range<ULong> ){
}
...
}
}
Do you understand my intension now ?
|
|
|
|
|
Yep, in that case you are going to end up with casting anyway. I'd treat the Range class as a structure, like Point. Anything that does any "work" should probably accept a Range class as a parameter - theres just too many potential uses for Range to make every usage scenario a member function. As long as you have say "IsBetween", "IsNotBetween" matching the Predicate< T > delegate then it should be useful enough.
If you are dealing with DataTables then you are dealing with objects, casting and constant invalidcastexceptions anyway, so I wouldnt worry too much
|
|
|
|
|
Mark Churchill wrote: If you are dealing with DataTables then you are dealing with objects, casting and constant invalidcastexceptions anyway, so I wouldnt worry too much [Wink]
Not quite
i use the range-class to built a sqlstatement and to determine whether i have to ask a Id-Colum or a DateTime-Column from a table
|
|
|
|
|
how can I write a double pointer like FILE **
|
|
|
|
|
Hi,
ahmedo047 wrote: how can I write a double pointer like FILE **
You can't directly. But why would you need it? The only thing that comes close is passing a
reference type (such as a File) to a method, in that case you can use the out or ref keywords
turning the parameter basically into a double indirection. Is that what you intend? If not,
please be more specific.
|
|
|
|
|
I am trying to convert (c#) the following c+++ code.I can be able to use the out or ref keywords for single pointer but I dont know how I can write double pointer
#include<stdio.h>
#include<math.h>
#define ZERO 1.0E-20
#define true 1
#define false 0
main()
{
double A,FA,B,FB,C,P,FP,TOL;
int I,NO,OK,FLAG;
FILE *OUP[1];
double absval(double);
double F(double);
void INPUT(int *, double *, double *, double *, double *, double *, int *);
void OUTPUT(FILE **, int *);
INPUT(&OK, &A, &B, &FA, &FB, &TOL, &NO);
if (OK) {
OUTPUT(OUP, &FLAG);
/* STEP 1 */
I = 1;
/* STEP 2 */
OK = true;
while ((I<=NO) && OK) {
/* STEP 3 */
/* compute P(I) */
C = (B - A) / 2.0;
P = A + C;
/* STEP 4 */
FP = F(P);
if (FLAG == 2) fprintf(*OUP,"%3d %15.8e %15.7e \n",I,P,FP);
if ((absval(FP)<zero)> /* procedure completed successfully */
fprintf(*OUP,"\nApproximate solution P = %11.8f \n",P);
fprintf(*OUP,"with F(P) = %12.8f\n",FP);
fprintf(*OUP,"Number of iterations = %3d",I);
fprintf(*OUP," Tolerance = %15.8e\n",TOL);
OK = false;
}
else {
/* STEP 5 */
I++;
/* STEP 6 */
/* compute A(I) and B(I) */
if ((FA*FP) > 0.0) {
A = P; FA = FP;
}
else {
B = P; FB = FP;
}
}
}
if (OK) {
/* STEP 7 */
/* procedure completed unsuccessfully */
fprintf(*OUP,"\nIteration number %3d",NO);
fprintf(*OUP," gave approximation %12.8f\n",P);
fprintf(*OUP,"F(P) = %12.8f not within tolerance : %15.8e\n",FP,TOL);
}
fclose(*OUP);
}
return 0;
}
/* Change function F for a new problem */
double F(double X)
{
double f;
f = ( X + 4.0 ) * X * X - 10.0;
return f;
}
void INPUT(int *OK, double *A, double *B, double *FA, double *FB, double *TOL, int *NO)
{
double X;
char AA;
printf("This is the Bisection Method.\n");
printf("Has the function F been created in the program immediately preceding\n");
printf("the INPUT function?\n");
printf("Enter Y or N\n");
scanf("%c",&AA);
if ((AA == 'Y') || (AA == 'y')) {
*OK = false;
while (!(*OK)) {
printf("Input endpoints A < B separated by blank\n");
scanf("%lf %lf", A, B);
if (*A > *B) {
X = *A; *A = *B; *B = X;
}
if (*A == *B) printf("A cannot equal B\n");
else {
*FA = F(*A);
*FB = F(*B);
if (*FA*(*FB) > 0.0) printf("F(A) and F(B) have same sign\n");
else *OK = true;
}
}
*OK = false;
while(!(*OK)) {
printf("Input tolerance\n");
scanf("%lf", TOL);
if (*TOL <= 0.0) printf("Tolerance must be positive\n");
else *OK = true;
}
*OK = false;
while (!(*OK)) {
printf("Input maximum number of iterations - no decimal point\n");
scanf("%d", NO);
if (*NO <= 0) printf("Must be positive integer\n");
else *OK = true;
}
}
else {
printf("The program will end so that the function F can be created\n");
*OK = false;
}
}
void OUTPUT(FILE **OUP, int *FLAG)
{
char NAME[30];
printf("Select output destination\n");
printf("1. Screen\n");
printf("2. Text file\n");
printf("Enter 1 or 2\n");
scanf("%d", FLAG);
if (*FLAG == 2) {
printf("Input the file name in the form - drive:name.ext\n");
printf("A:OUTPUT.DTA\n");
scanf("%s", NAME);
*OUP = fopen(NAME, "w");
}
else *OUP = stdout;
fprintf(*OUP,"Bisection Method\n");
printf("Select amount of output\n");
printf("1. Answer only\n");
printf("2. All intermeditate approximations\n");
printf("Enter 1 or 2\n");
scanf("%d", FLAG);
if (*FLAG == 2) fprintf(*OUP, " I P F(P)\n");
}
/* Absolute Value Function */
double absval(double val)
{
if (val >= 0) return val;
else return -val;
}
|
|
|
|
|
You don't need a double pointer. Both an array and a Stream are reference types, so if you pass a Stream array to a method you get the same effect as a double pointer. You don't even have to pass the array by reference.
However, as there is only ever one file pointer in the array, the array is pointless in the first place.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|