如题谢谢。我只找到操作单个列是否只读,但我现在需要一个列里的某些cell只读。
解决方案 »
- ★☆★☆★☆★★☆★简单的将某一个文件(不是图片文件)插入到数据库中,但死活都不成功,请高手赐教,感激不尽!!
- 多文檔界面碰到的問題。頂者有分。
- 程序保存?
- SOS! PrintDBGridEh调用PrinterSetupDialog设置打印机纸纸方向后,然后在预览和打印中居然不起效?
- 散分,散分了,看美女 UP就有分
- 软件发布前的一个小问题?再线等候!!!!马上揭贴
- 在fastreport中怎样截取一个字符串的左4个字符和右4个字符?
- delphi6有补丁吗?
- help:基于 delphi6.0 mapx3.0 sql2000 的程序调试
- 有关EDIT的一个小问题
- 急求!Delphi可调用的 DES或其他对称加密DLL
- 如何动态生成clientdataset的internalcalc字段
---------------------------------------------
什么的enabled?cxGridDBTableView的?
if (TableView.Controller.FocusedRecord.Values[需要判断的列] = 值) and (AItem.Index= 第几列) then
AAllow := False
else
AAllow := True;
Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem;
var AAllow: Boolean);
begin
inherited;
if AItem.ID in[0,1,2,3,4,5,6,7,9] then
begin
AAllow:=False;
cxGrid3DBTableView1Column9.Properties.ReadOnly:=True;
end;
if AItem.ID=0 then
begin
if cxGrid3DBTableView1.DataController.Controller.FocusedRecord.Values[10]='0' then
begin
AAllow:=False;
cxGrid3DBTableView1Column9.Properties.ReadOnly:=True;
MessageDlg('提示:已鎖定,此筆材料不能作替代料!',mtWarning,[mbOK],0);
Exit;
end
else
begin
if cxGrid3DBTableView1.DataController.Controller.FocusedRecord.Values[6]<>'00' then
begin
AAllow:=False;
cxGrid3DBTableView1Column9.Properties.ReadOnly:=True;
MessageDlg('提示:已鎖定,此筆材料不能作替代料!',mtWarning,[mbOK],0);
Exit;
end
else
AAllow:=True;
cxGrid3DBTableView1Column9.Properties.ReadOnly:=False;
end;
end;
end;
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters,
dxSkinsCore, dxSkinLondonLiquidSky, cxStyles, cxCustomData, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, ADODB, cxGridLevel, cxClasses,
cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
cxGrid, cxExtEditRepositoryItems;type
TForm1 = class(TForm)
cxGrid1DBTableView1: TcxGridDBTableView;
cxGrid1Level1: TcxGridLevel;
cxGrid1: TcxGrid;
Dst_1: TADODataSet;
Dst_1Check: TBooleanField;
Dst_1str: TStringField;
Dst_1str2: TStringField;
Ds_1: TDataSource;
cxGrid1DBTableView1Check: TcxGridDBColumn;
cxGrid1DBTableView1str: TcxGridDBColumn;
cxGrid1DBTableView1str2: TcxGridDBColumn;
cxEditRepository1: TcxEditRepository;
Lbl_Porp: TcxEditRepositoryLabel;
procedure FormCreate(Sender: TObject);
procedure cxGrid1DBTableView1strGetProperties(
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
var AProperties: TcxCustomEditProperties);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.cxGrid1DBTableView1strGetProperties(
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
var AProperties: TcxCustomEditProperties);
begin
if ARecord.Values[0] then //根据check字段的值判断
AProperties := Lbl_Porp.Properties;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
Dst_1.CreateDataSet;
Dst_1.AppendRecord([False,'t1','t2']);
Dst_1.AppendRecord([False,'x1','x2']);
Dst_1.AppendRecord([False,'z1','z2']);
Dst_1.AppendRecord([False,'y1','y2']);
Dst_1.AppendRecord([False,'c1','c2']);
Dst_1.AppendRecord([False,'a1','a2']);
Dst_1.AppendRecord([False,'e1','e2']);
end;end.
窗体文件object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 216
ClientWidth = 426
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object cxGrid1: TcxGrid
Left = 0
Top = 0
Width = 426
Height = 216
Align = alClient
TabOrder = 0
ExplicitLeft = 8
ExplicitTop = 8
ExplicitWidth = 410
ExplicitHeight = 200
object cxGrid1DBTableView1: TcxGridDBTableView
NavigatorButtons.ConfirmDelete = False
NavigatorButtons.First.Visible = True
NavigatorButtons.PriorPage.Visible = True
NavigatorButtons.Prior.Visible = True
NavigatorButtons.Next.Visible = True
NavigatorButtons.NextPage.Visible = True
NavigatorButtons.Last.Visible = True
NavigatorButtons.Insert.Visible = True
NavigatorButtons.Append.Visible = False
NavigatorButtons.Delete.Visible = True
NavigatorButtons.Edit.Visible = True
NavigatorButtons.Post.Visible = True
NavigatorButtons.Cancel.Visible = True
NavigatorButtons.Refresh.Visible = True
NavigatorButtons.SaveBook.Visible = True
NavigatorButtons.GotoBook.Visible = True
NavigatorButtons.Filter.Visible = True
DataController.DataSource = Ds_1
DataController.Summary.DefaultGroupSummaryItems = <>
DataController.Summary.FooterSummaryItems = <>
DataController.Summary.SummaryGroups = <>
OptionsBehavior.FocusCellOnTab = True
OptionsBehavior.GoToNextCellOnEnter = True
OptionsBehavior.FocusCellOnCycle = True
OptionsCustomize.ColumnFiltering = False
OptionsCustomize.ColumnsQuickCustomization = True
OptionsData.Deleting = False
OptionsData.DeletingConfirmation = False
OptionsData.Inserting = False
OptionsView.FooterMultiSummaries = True
OptionsView.GroupByBox = False
object cxGrid1DBTableView1Check: TcxGridDBColumn
DataBinding.FieldName = 'Check'
end
object cxGrid1DBTableView1str: TcxGridDBColumn
DataBinding.FieldName = 'str'
OnGetProperties = cxGrid1DBTableView1strGetProperties
end
object cxGrid1DBTableView1str2: TcxGridDBColumn
DataBinding.FieldName = 'str2'
end
end
object cxGrid1Level1: TcxGridLevel
GridView = cxGrid1DBTableView1
end
end
object Dst_1: TADODataSet
Parameters = <>
Left = 48
Top = 40
object Dst_1Check: TBooleanField
FieldName = 'Check'
end
object Dst_1str: TStringField
FieldName = 'str'
end
object Dst_1str2: TStringField
FieldName = 'str2'
end
end
object Ds_1: TDataSource
DataSet = Dst_1
Left = 160
Top = 40
end
object cxEditRepository1: TcxEditRepository
Left = 232
Top = 88
object Lbl_Porp: TcxEditRepositoryLabel
end
end
end