如何自定义DBNavigator

本文介绍如何利用Delphi的DBNavigator组件,通过添加自定义标题、图形和扩展功能,提升用户体验。通过创建继承类并访问受保护的Buttons属性,可以实现自定义按钮的图形和标题。此外,通过OnMouseUp事件,还可以实现在按住CTRL键点击nbNext按钮时跳过多条记录的功能。
摘要由CSDN通过智能技术生成

"Ok, the DBNavigator does its job of navigating data and managing records. Unfortunately, my customers want more user-friendly experience, like custom button graphics and captions, ..."

“好吧,DBNavigator负责导航数据和管理记录。不幸的是,我的客户希望获得更多用户友好的体验,例如自定义按钮图形和标题,...”

This inquiry came from a Delphi developer searching for a way to enhance the power of the DBNavigator component. 

该查询来自Delphi开发人员,他们正在寻找一种增强DBNavigator组件功能的方法。

The DBNavigator is a great component—it provides a VCR-like interface for navigating data and managing records in database applications. Record navigation is provided by the First, Next, Prior, and Last buttons. Record management is provided by the Edit, Post, Cancel, Delete, Insert, and Refresh buttons. In one component Delphi provides everything you need, to operate on your data.

DBNavigator是一个很棒的组件—它提供了一个类似于VCR的界面,用于导航数据和管理数据库应用程序中的记录。 记录导航由“第一”,“下一个”,“上一个”和“最后一个”按钮提供。 记录管理由“编辑”,“发布”,“取消”,“删除”,“插入”和“刷新”按钮提供。 在一个组件中,Delphi提供了处理数据所需的一切。

However, as the author of the e-mail inquiry also stated, the DBNavigator lacks some features like custom glyphs, button captions, and others.

但是,正如电子邮件查询的作者所指出的那样,DBNavigator缺少某些功能,例如自定义标志符号,按钮标题等。

功能更强大的DBNavigator ( A More Powerful DBNavigator )

Many Delphi components have useful properties and methods that are marked invisible ("protected") to a Delphi developer. Hopefully, to access such protected members of a component, a simple technique called the "protected hack" can be used.

许多Delphi组件具有有用的属性和方法,这些属性和方法被Delphi开发人员标记为不可见(“受保护”)。 希望访问组件的此类受保护成员,可以使用一种称为“受保护的hack”的简单技术。

First, you'll add a caption to every DBNavigator button, then you'll add custom graphics, and finally, you'll OnMouseUp-enable each button. 

首先,向每个DBNavigator按钮添加一个标题,然后添加自定义图形,最后,对每个按钮启用OnMouseUp。

From the "boring" DBNavigator to either of:

从“无聊的” DBNavigator到以下任一:

  • Standard graphics and custom captions

    标准图形和自定义标题
  • Only captions

    仅字幕
  • Custom graphics and custom captions

    自定义图形和自定义标题

让我们摇滚吧 ( Let's Rock 'n' Roll )

The DBNavigator has a protected Buttons property. This member is an array of TNavButton, a descendant of TSpeedButton. 

DBNavigator具有受保护的Buttons属性。 该成员是TNavButton的数组,TNavButton是TSpeedButton的后代。

Since each button in this protected property inherits from TSpeedButton, if you get our hands on it, you'

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值