如题谢谢。我只找到操作单个列是否只读,但我现在需要一个列里的某些cell只读。
解决方案 »
- 买源代码200元,外贸管理系统或外贸教学模拟平台
- 紧急求助:delphi与MFC算法结果不一致.
- 关于检测代理服务器是否可用?
- 三层架构问题的一些困扰, 大家进来看看,相互学习学习共同进步。
- 谁写过被ASP调用的组件,我写的最简单都不运行,我出100分买一个最简单的例子。
- 如何得到scrollbar的横竖那个移动滑块的移动距离!!
- 項目與數據庫連接問題(對你來說簡單,都來給我建議吧!)
- Delphi 会被 Visual Studio.net 打败吗?(请所有 Delphi 爱好者进来)
- 请问高手,如何判断一个数据库是不是在编辑装态?
- 有没有人知道修改delphi vcl的源文件,怎么重新编译成dcu
- 急求!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