VB 6.0 中的数据网格 6
我在 VB 6 应用程序中使用数据网格。我有一个记录集,其中有记录。现在我将此记录集分配给表单中的数据网格,但数据网格未显示任何数据。 任何帮助将不胜感激。提前谢谢。
I am using a datagrid in my VB 6 application. I have a recordset, which is having records. Now i assign this recordset to my datagrid in the form, yet the datagrid is not displaying any data.
Any help will be much appreciated. Thankx in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先要检查的是您是否正确配置了 DataGrid 的列以匹配您的记录集。
您可以在设计时或在运行时将 DataGrid 的数据源设置为数据环境。根据您的问题,我假设您在运行时将数据源设置为 ADODB 记录集?
为了正确显示记录集中的数据,您需要配置 DataGrid 的列。为此,请在设计时右键单击网格并选择编辑选项,如下所示。
再次右键单击网格,然后单击上下文菜单中的插入/删除/追加选项,直到出现您想要显示的正确列数。
添加列后,再次右键单击网格,选择“属性”并转到“列”选项卡,如下所示。
对于您定义的每一列,您需要输入一个标题以显示为列标题和数据字段您的记录集中的名称应显示在此列中。
完成此操作后,记录集中的数据应该正确显示。请注意,您需要使用可添加书签的游标类型(adOpenKeyset、adOpenStatic)打开记录集,否则在启动应用程序时将收到运行时错误。
The first thing to check is that you have the columns of the DataGrid configured correctly to match your recordset.
You can set the DataSource of the DataGrid either at design time to a DataEnvironment or at runtime. I'm presuming based on your question that you are setting the DataSource at runtime to an ADODB recordset?
In order to display the data in your recordset properly you need to configure the columns of your DataGrid. To do this right click the grid at design time and select the edit option as shown below.
Right click the grid again and click the either insert/delete/append options from the context menu until you have the correct number of columns that you want to display.
Once you've added the columns right click the grid again, select Properties and go to the Columns tab as shown below.
For each column you've defined you need to enter a caption to display as the column header and also the DataField name from you recordset that should be shown in this column.
Once you've done this the data from your recordset should display properly. Note that you need to open the recordset with a bookmarkable cursor type (adOpenKeyset, adOpenStatic) or you will receive a run time error when you launch the application.