Question

I have a fowm with a TAdvStringGrid component. Column 0 of the grid contains a nonsequential group of integers and column 1 contains a string, which may be empty or one word. Column 1 has an edComboList inplace editor that includes the allowable values. I'm trying to set the values in column 1 in a routine.

The code below works, except on the currently selected cell. The text value in that cell remains unchanged. I suspect it has to do with the fact that there is an editor for that column, but I can't figure out how to either disable the editor before doing the update, or even determine which is the currently selected cell in code.

int MyForm::SetAC(String & Flt, String & AC) {
   TFindParams fp = TFindParams();
   fp << fnFindInPresetCol << fnMatchFull;
   // sgFlights is the name of the TAdvStringGrid
   TPoint p = sgFlights->Find(TPoint(0, 0), Flt, fp);
   if (p.y > 0) {
      sgFlights->Cells[1][p.y] = AC;

   }
   return p.y;
}
void MyForm::LoadFACfromGDB() {
     std::map<int, String>FlightMatcher;
     // .. code to populate flight matcher...
      map<int, String>::const_iterator itr;
      for (itr = FlightMatcher.begin(); itr != FlightMatcher.end(); ++itr) {
         String Flt = IntToStr(itr->first);
         String AC = itr->second;
         SetAC(Flt, AC);
}
Was it helpful?

Solution

The solution I found to this problem was to remove the selection. Surprisingly the ClearSelection method doesn't do that. In this case I have one fixed row and one fixed column, so setting the selection to 0,0 effectively removes it.

   TGridRect gr = sgFlights->Selection;
   gr.Top = 0;
   gr.Bottom = 0;
   sgFlights->Selection = gr;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top