Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2002.01.17;
Скачать: [xml.tar.bz2];

Вниз

Что показывает DBGrid   Найти похожие ветки 

 
Labert   (2001-12-26 11:20) [0]

Как определить, какие записи в данный момент показывает DBGrid?

Заранее спасибо.


 
Turalyon   (2001-12-26 11:23) [1]

В смысле каие запииси? Которые ты в результате запроса получил. Или какие в таблице хранятся. Что именно тебя интересует???


 
Labert   (2001-12-26 17:40) [2]

Те записи, которые видны на экране в данный момент. Предроложим, в запросе 1000 записей, а на экране одновременно видны только 10. Пользователь перемещается по набору (с помощью scrollbarов), а программе нужно определить, какие записи пользователь видит в данный момент. Надеюсь, теперь я ясно объяснил?


 
Дремучий   (2001-12-26 19:55) [3]

может быть tbXXXXX.RecNo чем-то поможет?


 
SergVlad   (2001-12-26 22:28) [4]

А зачем определять ?


 
Labert   (2001-12-26 22:28) [5]

To Дремучий:

Текущая запись в DataSet и то, что показывает DBGrid - не одно и то же.
Текущая запись вообще может быть не видна.


 
Labert   (2001-12-27 09:28) [6]

To SergVlad:
Хочу сделать всплывающую подсказку на DBGride, которая показывает значение ячейки, над которой находится курсор. (Т.к. иногда строковое значение не влезает по ширине.)
Для этого-то и нужно определить, какие записи видны в данный момент на экране.
Задача, в общем, не ахти какая важная. Можно считать это просто интересной головоломкой.


 
Alx2   (2001-12-27 10:28) [7]

Решение головоломки:
Значение ячейки, над которой курсор, отражается на Label1.
PS
Писано "на скорую руку"...

procedure TForm1.MainDBGridMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
Var
Cell: TGridCoord;
Column : TColumn;
BM : TBookMark;
deltaRow : integer;
aDataSet : TDataSet;
begin
aDataSet := MainDBGrid.DataSource.DataSet;
BM := aDataSet.GetBookmark;
aDataSet.DisableControls;
try
Cell := MainDBGrid.MouseCoord(X, Y);
if (Cell.X < MainDBGrid.IndicatorOffset) or (Cell.Y < 0) then Exit;

Column := MainDBGrid.Columns[Cell.X-MainDBGrid.IndicatorOffset];
deltaRow := Cell.Y-MainDBGrid.Row;
aDataSet.MoveBy(deltaRow);

Label1.Caption := Column.Field.AsString;

finally
with aDataSet do
begin
GotoBookmark(BM);
FreeBookmark(BM);
aDataSet.EnableControls;
end;
end;
end;


 
Alx2   (2001-12-27 10:35) [8]

Дополнение: MainDBGrid : TDBGRidEh; (из EhLib)

Сейчас попробую для стандартного DBGrid.


 
Alx2   (2001-12-27 10:47) [9]

Получилось!

Type
TMyGrid = class (TDBGrid)
public
property IndicatorOffset;
property Row;
end;

procedure TMainForm.MainDBGridMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
Var
Cell: TGridCoord;
Column : TColumn;
BM : TBookMark;
deltaRow : integer;
aDataSet : TDataSet;

begin
aDataSet := MainDBGrid.DataSource.DataSet;
BM := aDataSet.GetBookmark;
aDataSet.DisableControls;
try
Cell := MainDBGrid.MouseCoord(X, Y);
if (Cell.X < TMyGrid(MainDBGrid).IndicatorOffset) or (Cell.Y < 0) then Exit;

Column := MainDBGrid.Columns[Cell.X-TMyGrid(MainDBGrid).IndicatorOffset];
deltaRow := Cell.Y-TMyGrid(MainDBGrid).Row;
aDataSet.MoveBy(deltaRow);

Label6.Caption := Column.Field.AsString;

finally
with aDataSet do
begin
GotoBookmark(BM);
FreeBookmark(BM);
EnableControls;
end;
end;
end;



 
Bizon   (2001-12-27 10:58) [10]

Рекомендую скачать компонент: SMDBGrid.
Он позволяет:
1. Выводить подсказки.
2. Многострочные столбцы.
3. Графика в ячейках.
4. CheckBox в ячейках.
И прочие вариации с разными цветами строк, ячеек и т.д.
Адрес:
http://www.geocities.com/SiliconValley/Grid/3989/download/smdbgrid.zip


 
Labert   (2001-12-27 11:49) [11]

To Alx2:
А что это за свойства такие, если не секрет:

property IndicatorOffset;
property Row


To Bizon:
Не скачивается!
"this page is currently unavailable" :(


 
Alx2   (2001-12-27 11:59) [12]

To Labert:
См. Help:

TCustomDBGrid.IndicatorOffset
Indicates the index of the first column in the grid that contains data.

property IndicatorOffset: Byte;

Description

Use IndicatorOffset to convert between the positions of the columns in the Columns property and the columns drawn on the data-aware grid. IndicatorOffset is 1 if the Options property includes dgIndicator, because the first column of the grid is used for the current row indicator. IndicatorOffset is 0 if all columns contain data.

---------------------
TCustomGrid.Row
Specifies the index of the row that contains the selected cell.

property Row: Longint;

Description

Use Row at runtime to determine the current row in the grid. Setting Row moves focus to the cell in the current column that is in the new row. The first row has an index of 0, the second row an index of 1, and so on.

The selected cell in the grid can be located by reading the Row property and the Col property to obtain the indexes of its row and column. When focus moves to the grid, the selected cell gets input focus.



Страницы: 1 вся ветка

Форум: "Основная";
Текущий архив: 2002.01.17;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.47 MB
Время: 0.003 c
14-52656
kimblch
2001-11-21 05:09
2002.01.17
Как востановить исходники


3-52501
ripp
2001-12-15 15:40
2002.01.17
Повтор. Помогите!


1-52600
Romul
2001-12-29 17:10
2002.01.17
Вопрос по TThread


3-52491
ripp
2001-12-15 15:21
2002.01.17
Как наити строку


1-52527
tovSuhov
2001-12-27 14:30
2002.01.17
Люди!!! Вот такой вопрос...





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский