'我用TextBox 和Command 组合做了一个控件,怎么才能把textbox 的 datasource 和datafield 属性在新控件的属性区中显示

南山明月 2005-11-24 09:55:23
'我用TextBox 和Command 组合做了一个控件,怎么才能把textbox 的 datasource 和datafield 属性在新控件的属性区中显示
...全文
143 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
韧恒 2005-12-02
  • 打赏
  • 举报
回复
这种情况应该是这样处理:
首先,你的控件应该有一个Text属性(当然起其他名字也行),将它委派给Text1.Text,这样你的控件代码中应该有如下代码。

'注意!不要删除或修改下列被注释的行!
'MappingInfo=Text1,Text1,-1,Text
Public Property Get Text() As String
Text = Text1.Text
End Property

Public Property Let Text(ByVal New_Text As String)
Text1.Text() = New_Text
PropertyChanged "Text"
End Property

'从存贮器中加载属性值
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Text1.Text = PropBag.ReadProperty("Text", "Text1")
End Sub

'将属性值写到存储器
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("Text", Text1.Text, "Text1")
End Sub

然后,点击“工具->过程属性”菜单,弹出“过程属性对话框”,在名称列表中选择“Text”,再点击“高级>>”按钮,在下面的“属性为数据绑定”和“绑定该属性到数据字段”两个检查框中打勾,最后点击“确定”按钮即可。
南山明月 2005-12-02
  • 打赏
  • 举报
回复
这么久了没人来了吗
南山明月 2005-11-28
  • 打赏
  • 举报
回复
还有没有利害点的,进来帮帮
faysky2 2005-11-24
  • 打赏
  • 举报
回复
搞不出来,Up
南山明月 2005-11-24
  • 打赏
  • 举报
回复
Public Property Get DataSource() As Variant
set DataSource = text1.DataSource '我用set
End Property

Public Property Let DataSource(ByVal vNewValue As Variant)
text1.DataSource = vNewValue
PropertyChanged "Datasource"
End Property
'我用set 没提示错误但属性窗口中没有
南山明月 2005-11-24
  • 打赏
  • 举报
回复
Public Property Get DataSource() As Variant
DataSource = text1.DataSource
End Property

Public Property Let DataSource(ByVal vNewValue As Variant)
text1.DataSource = vNewValue
PropertyChanged "Datasource"
End Property
说类型不匹配
南山明月 2005-11-24
  • 打赏
  • 举报
回复
没用呀
faysky2 2005-11-24
  • 打赏
  • 举报
回复
Public Property Get DataField() As Variant

End Property

Public Property Let DataField(ByVal vNewValue As Variant)

End Property

Public Property Get DataSource() As Variant

End Property

Public Property Let DataSource(ByVal vNewValue As Variant)

End Property
faysky2 2005-11-24
  • 打赏
  • 举报
回复
你得给新控件写属性才能显示

1,453

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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