Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

Несколько вопросов по StringGrid [D7, XP]


Страницы:   1 2 3 4 5

uno-84 ©   (2008-07-02 08:41:00) 

Здравстуйте! У меня несколько вопросов по StringGrid, я добавляю в него записи

with StringGrid1 do
          begin
             RowCount := k+1;
             for i := 1 to RowCount do
             begin
                  if FieldByName('MESSAGE_IMPORTANCE').AsString = 'T' then StringGrid1.Cells[0, i] := '!' else StringGrid1.Cells[0, i] := '';
                  if FieldByName('MESSAGE_ATTACH_COUNT').AsInteger > 0 then StringGrid1.Cells[1, i] := FieldByName('MESSAGE_ATTACH_COUNT').AsString
                     else StringGrid1.Cells[1, i] := '';    
                  if FieldByName('MESSAGE_ORIGINALMSG').AsString > '' then StringGrid1.Cells[2, i] := 'Ответ' else StringGrid1.Cells[2, i] := '';
                  if FieldByName('MESSAGE_NOTIFY').AsString = 'T' then StringGrid1.Cells[3, i] := '+' else StringGrid1.Cells[3, i] := '-';
                  if FieldByName('MESSAGE_TYPE').AsString = 'R' then StringGrid1.Cells[4, i] := 'Извещение о прочтении'
                     else
                     begin
                          if FieldByName('MESSAGE_WORK_TYPE').AsString = 'T' then
                          begin
                          StringGrid1.Cells[5, i] := FieldByName('MESSAGE_WORK_PRO').AsString + '%';
                          StringGrid1.Cells[4,i] := 'Служебное задание';
                          end
                           else
                           begin
                           StringGrid1.Cells[4, i] := 'Обычное сообщение';
                           StringGrid1.Cells[5, i] := '';
                           end;
                     end;

                  StringGrid1.Cells[6, i] := FieldByName('USER_NAME1').AsString;
                  StringGrid1.Cells[7, i] := FieldByName('MESSAGE_RECIPIENTS_NAMES').AsString;
                  StringGrid1.Cells[8, i] := FieldByName('USER_NAME').AsString;
                  StringGrid1.Cells[9, i] := FieldByName('MESSAGE_SUBJECT').AsString;
                  StringGrid1.Cells[10, i] := FieldByName('MESSAGE_SEND_DATE').AsString;
                  StringGrid1.Cells[11, i] := FieldByName('MESSAGE_RECEPT_DATE').AsString;
                  StringGrid1.Cells[12, i] := FieldByName('MESSAGE_READ_DATE').AsString;
                  StringGrid1.Cells[13, i] := FieldByName('MESSAGE_ID').AsString;
            Next;
            end;
1. Можно ли вставить в StringGrid1.Cells[14, i] CheckBox и как отслеживать поставлен чек или нет?
2. В Cells[5, i] нежен прогресс бар или что-то в этом роде, для визуального представления процента?
3. Как сделать так что-бы записи писались по центру ячейки?
Подскажите пожалуйста.
Заранее спасибо


Sergey13   (2008-07-02 09:46:00) [81]

> [0] uno-84   (02.07.08 08:41)

Я так понимаю что твои FieldByName-ы из какого-то датасета? Почему тогда не DBGrid?


han_malign   (2008-07-02 09:38:00) [82]

Перекрыть DrawCell(OnDrawCell) и отрисовывать что угодно и как угодно...
1. Как отрисовать CheckBox можно посмотреть в модуле CheckLst - TCheckListBox.DrawCheck. Состояние можно хранить в Objects (Objects[c,r]:= TObject(1); case integer(Objects[c,r]) of ...).
2.
procedure DrawSimpleHProgressBar(aCanvas: TCanvas; const aRect: TRect; aColor, aTextColor: TColor;
  aText: string; aPercent: byte; aHCenterText: boolean);
var W,H,X,Y: integer;
   _rect: TRect;
   _clr: TColor;
   _bs: TBrushStyle;
begin
  if(aPercent>100)then aPercent:=0;
  W:=aRect.Right-aRect.Left+1; H:=aRect.Bottom-aRect.Top+1;
  _rect:=aRect;
  if(aPercent>0)then begin
     _rect.Right:=aRect.Left+W*aPercent div 100-1;
     _clr:=aCanvas.Brush.Color;
     aCanvas.Brush.Color:=aColor;
     aCanvas.FillRect(_rect);
     aCanvas.Brush.Color:=_clr;
     aText:=aText+' '+IntStr(aPercent)+'%';
     _rect.Left:=_rect.Right+1;
     _rect.Right:=aRect.Right;
  end;
  if(_rect.Right>=_rect.Left)then aCanvas.FillRect(_rect);
  Y:=(H-aCanvas.TextHeight(aText))div 2;
  if(Y<0)then Y:=0;
  X:=(W-aCanvas.TextWidth(aText))div 2;
  if(X<0)then X:=0;
  if((X>Y)and not aHCenterText)then
     if(Y>0)then X:=Y
     else if(X>2)then X:=2;
  _bs:=aCanvas.Brush.Style;
  aCanvas.Font.Color:= aTextColor;
  aCanvas.Brush.Style:=bsClear;
  aCanvas.Refresh;
  aCanvas.TextOut(aRect.Left+X,aRect.Top+Y,aText);
  aCanvas.Brush.Style:=_bs;
end;

3. DrawText(Canvas.Handle, ...) вместо Canvas.TextOut/TextRect(...) и будет тебе щастье... хотя можно и вручную извратиться как в п.2.


Страницы:   1 2 3 4 5

Наверх

Титульная страница Поиск, карта сайта Написать письмо