为什么dbgrid会无法选中呢,点了一行后dbgrd1.SelectedRows.Count为0,dbgrd1.SelectedIndex为-1,以下是dbgrid的设置:
object dbgrd1: TDBGrid
Left = 0
Top = 209
Width = 567
Height = 331
Align = alClient
DataSource = DataSource2
Options = [dgTitles, dgIndicator, dgColumnResize, dgColLines, dgRowLines, dgTabs, dgRowSelect, dgConfirmDelete, dgCancelOnExit]
ReadOnly = True
TabOrder = 1
TitleFont.Charset = GB2312_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -12
TitleFont.Name = #23435#20307
TitleFont.Style = []
OnCellClick = dbgrdVirusCellClick
OnDrawColumnCell = dbgrdVirusDrawColumnCell
end
object dbgrd1: TDBGrid
Left = 0
Top = 209
Width = 567
Height = 331
Align = alClient
DataSource = DataSource2
Options = [dgTitles, dgIndicator, dgColumnResize, dgColLines, dgRowLines, dgTabs, dgRowSelect, dgConfirmDelete, dgCancelOnExit]
ReadOnly = True
TabOrder = 1
TitleFont.Charset = GB2312_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -12
TitleFont.Name = #23435#20307
TitleFont.Style = []
OnCellClick = dbgrdVirusCellClick
OnDrawColumnCell = dbgrdVirusDrawColumnCell
end
你要在Options中加上dgMultiSelect这个属性,select的属性才有