herculanojs Posted April 24, 2018 Share Posted April 24, 2018 I am facing problematic with the onDrwaCell event of UniStrigGrid. This event is only triggered once when the StringGrid is mounted. After even manipulating the values of the grid this event does not fire any more. What is the solution to this? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 24, 2018 Share Posted April 24, 2018 Hi, Which build are you using? Can you please explain in more detail what problem do you have? Quote Link to comment Share on other sites More sharing options...
herculanojs Posted April 24, 2018 Author Share Posted April 24, 2018 Build 1.0.0.1424 The UniStringGrid is changed in this procedure. Yet by no means ondrawcell is being fired. It is triggered only once when the procedure is first performed. a) Stringgrid tuning procedure procedure TfrmAgendamento.UpdateCalendar; var AYear, AMonth, ADay: Word; FirstDate: TDateTime; ACol,ARow:integer; begin FUpdating := True; try sgCalendario.ColCount := 7; sgCalendario.RowCount := 7; DecodeDate(FDate, AYear, AMonth, ADay); FirstDate := EncodeDate(AYear, AMonth, 1); { day of week for 1st of month } FMonthOffset := 2 - ((DayOfWeek(FirstDate) - FStartOfWeek + 7) mod 7); for ACol := 0 to 6 do for ARow := 0 to 6 do sgCalendario.Cells[ACol,ARow] := GetCellText(Acol,Arow); sgCalendario.HeaderTitle := IntToStr(day)+' de '+MonthText+'/'+IntToStr(Year)+' ('+formatdatetime('dddd',CalendarDate)+')'; DrawEvents; sgCalendario.Repaint; Invalidate; { trigger OnDateChange and all HookEvents } if Assigned(FDateChange) then FDateChange(Self, FDate); finally FUpdating := False; end; end; OnDrawCell (procedure) procedure TfrmAgendamento.sgCalendarioDrawCell(Sender: TObject; ACol, ARow: Integer; var Value: string; Attribs: TUniCellAttribs); var DayNumStr : string; wOutStr : String; wYear : Word; wMonth : Word; wDay : Word; wLeft : Integer; i,f: integer; ADate: TDateTime; begin DayNumStr:=CellText[ACol, ARow]; Attribs.Font.Color := clBlack; Attribs.Color := clWhite; if ((ACol = 0) or (ACol = 6)) and FBlockWeekends and (DayNumStr<>'') and (ARow <> 0) then Attribs.Color := BlockedColor; If (ARow=0) Then Begin Attribs.Color := sgCalendario.FixedColor; Attribs.Font.Color := clBlack; Attribs.Font.Style := [fsBold]; End; if (FHiliteSunday) And (ACol=0) And (ARow<>0) then Attribs.font.color:=clRED; If (ARow>0) Then Begin IF DayNumStr<>'' Then Begin DecodeDate(Now,wYear,wMonth,wDay); If (wYear=Year) and (wMonth=Month) and (wDay=StrToInt(DayNumStr)) Then Begin Attribs.Font.Style:=Attribs.Font.Style+[fsBold]; Attribs.Font.Color := clWhite; Attribs.Color := clNavy; End; End; if (Events.Count > 0) and (CellText[ACol, ARow] <> '') then begin DayNumStr := CellText[ACol, ARow]; i := GetDayEvent(StrToInt(DayNumStr),Month,Year); if (i <> -1) and (Events.Count >= I) then begin Attribs.Color := clyellow; Attribs.Font.Color := clred; end; end; end; end; Quote Link to comment Share on other sites More sharing options...
mos Posted May 4, 2018 Share Posted May 4, 2018 Hi Delphi Developer, Any update on this as it seems calling Invalidate does not trigger the OnDrawCell after the grid has been initially created? Build 1413. Quote Link to comment Share on other sites More sharing options...
mos Posted May 8, 2018 Share Posted May 8, 2018 Hi herculanojs, Did you manage to find a solution to this issue? Quote Link to comment Share on other sites More sharing options...
herculanojs Posted May 8, 2018 Author Share Posted May 8, 2018 The only possible solution is to have to redo the entire stringgrid Quote Link to comment Share on other sites More sharing options...
mos Posted May 9, 2018 Share Posted May 9, 2018 Yes I think that is the only way as well. The only possible solution is to have to redo the entire stringgrid Quote Link to comment Share on other sites More sharing options...
eduardosuruagy Posted April 22, 2019 Share Posted April 22, 2019 Hi herculanojs, Did you manage to find a solution to this issue? Quote Link to comment Share on other sites More sharing options...
eduardosuruagy Posted April 23, 2019 Share Posted April 23, 2019 Can someone help me please?? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 23, 2019 Share Posted April 23, 2019 1 minute ago, eduardosuruagy said: Can someone help me please?? Hi, Can you please clarify what problem do you have? Quote Link to comment Share on other sites More sharing options...
eduardosuruagy Posted April 23, 2019 Share Posted April 23, 2019 3 minutes ago, Sherzod said: Hi, Can you please clarify what problem do you have? I am facing problematic with the onDrwaCell event of UniStrigGrid. This event is only triggered once when the StringGrid is mounted. After even manipulating the values of the grid this event does not fire any more. What is the solution to this? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 23, 2019 Share Posted April 23, 2019 1 minute ago, eduardosuruagy said: What is the solution to this? Which build are you using? Can you make a simple testcase for reproduce? Quote Link to comment Share on other sites More sharing options...
eduardosuruagy Posted April 23, 2019 Share Posted April 23, 2019 I just installed the latest version, I'm going to do a test here and I'll send it okay !! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 23, 2019 Share Posted April 23, 2019 Ok Quote Link to comment Share on other sites More sharing options...
eduardosuruagy Posted April 23, 2019 Share Posted April 23, 2019 18 minutes ago, Sherzod said: Está bem I click on the column and change the value to 1, if the value is already in 1 I put it to 2 and the colors have to change according to the value, but if I click once on the column it changes the value and if I click again in the same column the value remains the same. The unigui does not recognize the second click on the same column, I have to click on another column so that I can click on the other column again. StringGrid Demo - Copia.rar Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 23, 2019 Share Posted April 23, 2019 1 hour ago, eduardosuruagy said: The unigui does not recognize the second click on the same column, I have to click on another column so that I can click on the other column again. This is normal behavior, because you are using OnSelectCell event Quote Link to comment Share on other sites More sharing options...
eduardosuruagy Posted April 23, 2019 Share Posted April 23, 2019 Is there another event that I can get around this situation? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 23, 2019 Share Posted April 23, 2019 I don't know why you want to use such code. 4 minutes ago, eduardosuruagy said: Is there another event that I can get around this situation? Yes, you can try to use OnClick event instead Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 23, 2019 Share Posted April 23, 2019 procedure TMainForm.UniStringGrid1Click(Sender: TObject); var _Value : String; grid: TUniStringGrid; begin grid := (Sender as TUniStringGrid); with grid do if (Row >= 0) then begin _Value := Cells[Col, Row]; if _Value = '1' then _Value := '2' else if _Value = '2' then _Value := '1' else _Value := '1'; Cells[Col, Row] := _Value; end; end; Quote Link to comment Share on other sites More sharing options...
eduardosuruagy Posted April 24, 2019 Share Posted April 24, 2019 22 hours ago, Sherzod said: procedure TMainForm.UniStringGrid1Click(Sender: TObject); var _Value : String; grid: TUniStringGrid; begin grid := (Sender as TUniStringGrid); with grid do if (Row >= 0) then begin _Value := Cells[Col, Row]; if _Value = '1' then _Value := '2' else if _Value = '2' then _Value := '1' else _Value := '1'; Cells[Col, Row] := _Value; end; end; Many thanks, it worked !! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.