Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / C++ [игнор отключен] [закрыт для гостей] / DBGrid / 2 сообщений из 2, страница 1 из 1
29.05.2007, 05:47
    #34556621
Ramana
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
DBGrid
Работаю с DBGrid. При помощи DataSource в ней показываются данные из нескольких связанных таблиц. Нужно как-то поставить условие доля выделенной строки DBGrid (если строка выделена, то выполнить действие).
...
Рейтинг: 0 / 0
31.05.2007, 10:56
    #34563598
gl@z
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
DBGrid
TCustomDBGrid::SelectedRows

Specifies a set of bookmarks for all the records in the dataset that correspond to rows selected in the grid.

__property TBookmarkList* SelectedRows = {read=FBookmarks};

Description

Use the properties and methods of the TBookmarkList object returned by SelectedRows to

Determine the number of rows in the grid that are selected.
Determine whether the current record in the dataset is selected.
Determine whether a particular record in the dataset is selected.
Delete all selected rows from the dataset.

SelectedRows is only meaningful when the Options property includes dgRowSelect and dgMultiSelect.

EXAMPLE:

The following example copies the selected rows in a db grid to a list box.

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  if (DBGrid1->SelectedRows->Count >  0 )
  {
    AnsiString s = "";
    TDataSet *pDS = DBGrid1->DataSource->DataSet;
    for (int i= 0 ; i < DBGrid1->SelectedRows->Count; i++)
    {
      pDS->GotoBookmark((void *)DBGrid1->SelectedRows->Items[i].c_str());
      for (int j =  0 ; j < pDS->FieldCount; j++)
      {
        if (j> 0 )
          s = s+", ";

        s = s + pDS->Fields->Fields[j]->AsString;
      }
      ListBox1->Items->Add(s);
      s = "";
    }
  }
}
...
Рейтинг: 0 / 0
Форумы / C++ [игнор отключен] [закрыт для гостей] / DBGrid / 2 сообщений из 2, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]