Quote:
I'm trying to test if I find the record I select with this code (in a Button) :
Code:
bool record_found = false;
while(!DM->Query->Eof && !bool record_found)
{
if(DBGrid->SelectedRows->CurrentRowSelected)
{
bool record_found = true;
}
DM->Query->Next();
}
Everytime, the first row don't seem to exist when I select it manually or not...
|
Looks like you're creating several instances of the
record_found here, have you tried:
Code:
bool record_found = false;
while(!DM->Query->Eof && !record_found)
{
if(DBGrid->SelectedRows->CurrentRowSelected)
{
record_found = true;
}
DM->Query->Next();
}
Since within the while loop the
bool record_found will create a new instance of record_found that resides in the while scope, and won't intervene with the
record_found declared outside the while scope.
Quote:
|
P.S. When I put the indicator to true, the "->" color is different when it's the first row...
|
What are you talking about?? a color changing when setting something to true, are you talking about the IDE you're developing in??
Quote:
|
P.S. I tried also "DBGrid->SelectedRows->Delete();" for deleting and even if I select only 1 row it delete ALL rows even if the "DBGrid->SelectedRows->Count" indicate that I selected only 1 row... Do these objects work propely or did I forget to do something?
|
It depends, if you have a flaw in your while loop, which makes it keep on going, then every row will eventualy be deleted.