如何使dbgrideh1.columns[0]的输入长度不能大于4?如同edit的maxlength一样

maginn 2003-10-15 06:40:57
希望达到如同edit的maxlength一样的效果,
即没有办法输入第五个字符??
...全文
136 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
monkey968 2003-10-19
  • 打赏
  • 举报
回复
同意上面老兄的说法 最后还是做一个录入界面 这样什么问题都解决了
bjhjh 2003-10-19
  • 打赏
  • 举报
回复
up

beforepost好象不让改?

就是说,我写完事件代码,指定时没有此事件名称?

请指教!!!
zswangII 2003-10-15
  • 打赏
  • 举报
回复
//控制数据的存储最好还是控制DataSet而不是控制其所对应的数据控件~~
procedure TForm1.Table1AfterOpen(DataSet: TDataSet);
begin
//如果你的字段是整数类型可以这样~~
TIntegerField(Table1.FieldByName('整数字段')).MaxValue := 1000;
//如果你的字段是字符类型可以这样~~
TStringField(Table1.FieldByName('字符字段')).Size := 4;
end;
maginn 2003-10-15
  • 打赏
  • 举报
回复
其它的放开不算,
是不是想在dbgrid中实现像edit的maxlength一样的控制不能实现阿?

用户需求如下(起因)
用dbgrid完成 输入信息 ;其中一个字段是时间字段(分:妙)
我只能限制输入的为“数值”信息(dbgrid的keypress)
然后在beforepost中判断是否为正确的时间信息,如正确插入,错误 提示错误信息
问题是
正确的格式为 4位数,前两位位“十分”,后两位位“妙”
这样的话用户可以无限的输入多个数字,而只有当离开该cell时候,才发出错误提示信息
我像限制一下用户的输入,
或者当输入两个字符的时候能自动的出来一个“:”间隔一下

我也尝试用dbgrid。的一个colums 的buttonstyle设成cbsEliispe用一个maskedit来完成
然后在dbgride的ditbuttonclick完成

可出现的问题是
1:点击了dbgrid的需要设定的colums出现maskedit了,但是如何当在maskedit中
输入的信息转存到dbgrid中那(每次都出现问题)?在maskedit的exit中如何完成那?
2:如何控制maskedit每次显示的位置?在当前“cell”上?且仅用一个maskedit来完成
我不定个数的“行”的添加??

如能解决上面的问题也可
谢谢
47522341 2003-10-15
  • 打赏
  • 举报
回复
在dbgrid中的操作是对数据集的操作;除非你设定了该字段的长度为4;
然后在beforepost中给点提示还可以;
WGYKING 2003-10-15
  • 打赏
  • 举报
回复
最好建一个录入界面!
maginn 2003-10-15
  • 打赏
  • 举报
回复
不可以在dataset中设定
说,不能这样操作在一个开的数据集中
hthunter 2003-10-15
  • 打赏
  • 举报
回复
数据绑定的数据长度好像不能在数据集打开的状态下设置,否则会报错。
假如你要限制的长度跟数据库设计时的长度不一样,那只能在ADODataset等的Fields Editor里面修改相应字段的Size(并且只能小于或等于数据库字段的设计长度)。如果要限制的长度跟数据库设计的长度是一致的,那不需要做什么设置,DBGrid会自动根据字段的长度来做限制。
maginn 2003-10-15
  • 打赏
  • 举报
回复
这么写为什么不去
TEdit(dbgrid1.Columns[0]).Maxlength:=4;
一、 DBGridEh(增强型表格组件)功能详解.....................................................................4 二、应用实例..........................................................................................................................5 1. 定制标题行......................................................................................................................5 1) 制作复杂标题行.......................................................................................................5 2) 按钮式标题..............................................................................................................5 3) 标题行显示图片.......................................................................................................5 4) 如根据不同状态在数据单元格中显示相应图片...................................................5 5) 自动显示标题行的升降排序标志符(▽降序△升序)并做相应排序...............6 6) 点dbgrideh 标题排序..............................................................................................7 7) 在DBGridEH 中怎样实现多重排序(标题出现0123等排列序号)? ................ 11 8) 让dbgrid显示序号................................................................................................ 11 2. 外观布局........................................................................................................................12 1) 根据不同字段值显示相应的小图片.....................................................................12 2) 显示检查框(checkbox)外观.............................................................................12 3) 显示单、多列下拉列表.........................................................................................12 4) 显示日历下拉列表.................................................................................................13 5) 3D或平面外观效果...............................................................................................13 6) 行头和列头的启用关闭.........................................................................................13 7) DBGrid如何实现透明效果?.................................................................................13 8) 滚动条的各种应用.................................................................................................16 9) 数据行高................................................................................................................19 10) DBGrid设置Rowheight后如何将单元格内容纵向和垂直都居中?..............19 11) 设置DBGridEH 自适应列宽的最好方法.........................................................20 12) Ehlib 的DBGridEh首列加序号........................................................................21 13) 分行分列、单元格的颜色设置.........................................................................23 14) 点击不同单元格列,执行不同的动作.............................................................27 15) 下拉式计算器.....................................................................................................28 16) 鼠标移到某个单元格,指针形状改变.............................................................28 17) 自动填充网格列宽到网格客户区.....................................................................29 18) 从注册表或ini文件中保存或恢复网格和列的层次。...................................29 3. 编辑功能........................................................................................................................29 1) 多选........................................................................................................................29 2) 文本多行显示.........................................................................................................30 3) 显示备注字段.........................................................................................................30 4) 如何让dbgrideh1 显示数据时只显示两位小数...................................................30 5) 获得当前DBGridEh表中单元格的序号.............................................................30 6) 怎样在dbgridEh和Edit中显示金额的千分号...................................................30 7) end;请问怎么才能使DBGridEh不滚动就能提交数据?...................................32 8) 我怎么把dbgrid 里的数据一次插入到数据库呢................................................32 9) 在DBGrid中可选中行而又可进入编辑状态......................................................32 10) 修正DBGrideh 丢失焦点时自动关闭输入法的问题......................................35 11) DBGRIDEH选定多行删除怎么实现...............................................................36 12) DBGrid 滚动表格的代码...................................................................................37 4. 统计功能........................................................................................................................37 白波九道整理自用版 第 3 页 1) 页脚合计................................................................................................................37 2) 定制表格底部(footer)区域的汇总统计行.......................................................38 3) TDBSumList说明..................................................................................................38 4) 如何工作以及为什么有时SumList的集合值计算不正确?.............................39 5) dbgrideh列求和.....................................................................................................39 5. 数据功能........................................................................................................................40 1) 查找字段点击某列值的下拉按纽弹出一个从数据库取值下拉列表...............40 2) 使用DBGridEh自动过滤实现方法.....................................................................40 3) 使用DBGridEh自动过滤实现方法2 ..................................................................41 4) DBGridEh 控件中使用过滤功能 (适用ehlib 5.2 ehlib 5.3)................................42 5) 支持模糊查询.........................................................................................................43 6) ehlib4.4.50中支持模糊匹配的修改方法..............................................................44 7) EhLib 5.0 Build 5.0.13的过滤字串都是模糊过滤修改.......................................45 8) 滚动条滚动时选择不变,还有自动过滤功能的实现.........................................45 9) 增量搜索................................................................................................................46 10) ehlib总是按两次ctrl+f才出来查找框,怎么办?.........................................46 11) 如何改良dbgrideh的文字过滤........................................................................46 12) 改进DBGrideh 表头点击自动排序,实现双击状态轮流.................................47 13) 改良Ehlib 的排序功能,加快排序速度.............................................................49 14) 在DbGridEh中显示TreeView效果................................................................50 15) DBGridEh-KeyList、PickList............................................................................51 16) 主从表设置........................................................................................................53 17) 在DbGridEh中显示表中表..............................................................................55 6. 输入/输出.......................................................................................................................56 1) 导入导出数据.........................................................................................................56 2) 从多种格式导入/导出数据到TDBGridEh...........................................................57 3) DBGRID 生成EXCEL报表.................................................................................57 4) 使用TPrintDBGridEh 组件.................................................................................61 5) 打印时确定Ehlib定义的报表表头颜色? ............................................................61 6) Ehlib 中的PrintDBGridEh如何印页码,即第几页共几页...................................62 7) 怎么让PrintDBGridEh只打印DbGridEh 中指定的列.......................................62 8) 怎样进行横向打印/ 打印预览?........................................................................62 7. 将存在的DBGrid组件转换为DBGridEh组件...........................................................62 三、EhLib安装问题.............................................................................................................64 1. EhLib 安装步骤.............................................................................................................64 2. EhLib 安装问题(dbsumlst.dcu出错) ..........................................................................64 3. 安装提示找不到.BPL文件...........................................................................................65 四、Delphi 下的优秀表格(Grid)显示控件........................................................................65 1. NextGrid .........................................................................................................................65 2. TopGrid 3.01...................................................................................................................65 3. XLGrid............................................................................................................................66 4. DevExpress ExpressQuantumGrid .................................................................................66 5. TMS Grid Pack...............................................................................................................68 6. EhLib ..............................................................................................................................71 白波九道整理自用版 第 4 页 7. ProfGrid..........................................................................................................................71 8. EasyGrid .........................................................................................................................71 五、delphi 中配置文件的使用(*.ini).........................................................................71 六、窗口动画效果Animatewindow应用...........................................................................72 七、Delphi Excel to Sql Server..............................................................................................73 八、Delphi控制Excel的经验如下:..................................................................................76
The history of the EhLib library -------------------------------- Version 6.1 + A new component TDBVertGridEh - DataSet Grid with the Vertical Orientation. The component is used to display and edit a single record of DataSet in a vertical orientation. Basic properties of the TDBVertGridEh: Rows: TDBVerGridRows - A collection of items of TFieldRowEh type to display fields of a record. This is analogous to the Columns collection in TDBGridEh. Options: TDBVHGridOptions - Configure basic properties of the vertical grid. RowsDefValues: TFieldRowDefValuesEh - default values for line Grid row - TFieldRowEh. This is analogous of ColumnDefValues in TDBGridEh. GridLineParams: TDBVertGridLineParamsEh - Color settings of the dividing lines in vertical grid. DataColParams: TDBVertGridDataColParamsEh - The setting of the column with data. LabelColParams: TDBVertGridLabelColParamEh - The setting of the column with row label. See an example of using TDBVertGridEh in a project: \ Demos \ DBVertGridEh.SimpleDemo \ Project1.dpr compiled project: \ Demos \ Bin \ DBVertGridEh.SimpleDemo.Exe * There are changes in the grids inheritance tree: New inheritance tree is: TCustomControl | - TCustomGridEh | - TCustomDBAxisGridEh | - TCustomDBGridEh | | | - TDBGridEh | - TCustomDBVertGridEh | - TDBVertGridEh * Some constants and procedures are moved from the module DBGridEh to the DBAxisGridsEh. + Added a new global function to display a ObjectInspector-like Form. Use the next procedure to display the ObjectInspector-like Form: procedure ShowObjectInspectorForm ( Component: TObject; // A component to Inspect FormBounds: TRect; // Form Borders NewForm: Boolean = False // Show as a new Form ); This is a simple ObjectInspector that can be used to debug property setting at run-time. See an example that shows how to use ShowObjectInspectorForm here: \ Demos \ ObjectInspectorForm.SimpleDemo \ Project1.dpr compiled project: \ Demos \ Bin \ ObjectInspectorForm.SimpleDemo.Exe In DBGridEh + Added an ability to change the size of RowDetailPanel by mouse at RunTime. New properties in RowDetailPanel: property VertSizing: Boolean - Show an RowDetailPanel Splitter at the buttom of the RowDetailPanel. property MinHeight: Integer - Minimum height of the RowDetailPanel. property MaxHeight: Integer - Maximum height of the RowDetailPanel. property SizingBarBeveled: Boolean - Splitter area has a 3D border. property SizingBarHeight: Integer - The height of the Splitter. + Added an ability to darken gray the grid while the data is loading. See StartLoadingStatus and FinishLoadingStatus methods in the TDBGridEh. See the example that shows this opportunity in a project: \ Demos \ DBGridEh.LoadingStatus \ Project1.dpr compiled project: \ Demos \ Bin \ DBGridEh.LoadingStatus.Exe

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧