borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Component Request Pending)Next Topic (I try to use the MSHFlexGrid in Access) New Topic New Poll Post Reply
AndreaVB Forum : ActiveX : ActiveX
Poster Message
hitech_huzefa
Level: Scholar

Registered: 23-06-2005
Posts: 40

icon ActiveX

Hi! i am back again.
These days i was busy working on a ActiveX control (TEXT BOX) which has many new features but i dont know how to put DataField DataSource and DataFormat on the control please help.

20-08-2005 at 04:38 AM
View Profile Send Email to User Show All Posts | Quote Reply
misterxed
Level: VB Lord


Registered: 12-06-2005
Posts: 151
icon Re: ActiveX

Hi,
Is it that u want to ask how do u add properties to a User control, or do u want to add specifically DATAFIELD, DATASOURCE etc? If ur answer is the former one, heres the code:


'General Section:

Private m_DataField as String

'When the user asks for the property, the following code is run:
Public Property Get DataField() As String
    DataField = m_DataField
End Property

'When s/he sets the property, following code is run:
Public Property Let DataField(ByVal NewValue As String)
    m_DataField = NewValue
End Property

'Initialization of the control...
Private Sub UserControl_InitProperties()
    m_DataField = ""
End Sub



'Whenever the control is destroyed:
'Note that control is destroyed, even when u switch from Design mode to Run mode (i.e. when u press F5)
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    PropBag.WriteProperty "DataField", m_DataField, ""
End Sub

'Whenever control is created...
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    DataField = PropBag.ReadProperty("DataField", "")
End Sub


Note that initialization takes place only ONCE, when a control is created. If more instances r created, they only READPROPERTIES and donot INITIALIZE...

Now that i've given a simple idea of what u're supposed to do, i'll get into little specifics for DataField:

Firstly, u'll have to determine if the control is being created in design mode or Run Mode.  For this, u can use the
UserControl.Ambient.UserMode
property. Then u can add the code for the DataField property... Something like this:


Public Property Let DataField(ByVal NewValue As String)
    m_DataField = NewValue
   If UserControl.Ambient.UserMode Then
        'Add code here to do whatever DATAFIELD property does
   End If
End Property


____________________________
lOsT...

23-08-2005 at 02:51 AM
View Profile Send Email to User Show All Posts | Quote Reply
hitech_huzefa
Level: Scholar

Registered: 23-06-2005
Posts: 40
icon Re: ActiveX

why the default property of a TextBox is not showing when i put the ActiveX control on the form as a DataField, DataSource,DataFormat. i was going through a activeX control i saw the above property was availab but when i created a TextBox ActiveX control the Properties was gone why and how please help.

23-08-2005 at 05:29 AM
View Profile Send Email to User Show All Posts | Quote Reply
misterxed
Level: VB Lord


Registered: 12-06-2005
Posts: 151
icon Re: ActiveX

I think i got ur point:
U added a Textbox to ur own control, then u added this control to a Form, to check ur control... And u're not getting the DataField property in ur control... RIGHT?
Well, once u've added any other control to the USERCONTROL (that's what i will call ur control) that control becomes a part of ur control, but its properties are not automatically transferred to ur control.. for that, heres a sample:
Add a text box in USERCONTROL then,



'General Section:

Private m_DataField As String

'When the user asks for the property, the following code is run:
Public Property Get DataField() As String
    DataField = m_DataField
End Property

'When s/he sets the property, following code is run:
Public Property Let DataField(ByVal NewValue As String)
    m_DataField = NewValue
    Text1.DataField = m_DataField
End Property

'Initialization of the control...
Private Sub UserControl_InitProperties()
    m_DataField = ""
End Sub

'Whenever the control is destroyed:
'Note that control is destroyed, even when u switch from Design mode to Run mode (i.e. when u press F5)
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    PropBag.WriteProperty "DataField", m_DataField, ""
End Sub

'Whenever control is created...
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    DataField = PropBag.ReadProperty("DataField", "")
End Sub



This way u can add all other properties of textbox into ur USERCONTROL...



[Edited by misterxed on 24-08-2005 at 12:36 AM GMT]

____________________________
lOsT...

23-08-2005 at 07:23 PM
View Profile Send Email to User Show All Posts | Quote Reply
hitech_huzefa
Level: Scholar

Registered: 23-06-2005
Posts: 40
icon Re: ActiveX

i did successfully DataFeld but how to do DataSource?

if it is possible can u make a little textbox activex control with DataFiled, DataSource and DataFormat properties and send it to me on shuzefa@rediffmail.com or upload on this site so that others can also see.Please

25-08-2005 at 04:49 AM
View Profile Send Email to User Show All Posts | Quote Reply
misterxed
Level: VB Lord


Registered: 12-06-2005
Posts: 151
icon Re: ActiveX

hi,
I tried a lot of things on DataSource, but i seem to find no solution.... Its strange though..
I ususally advise ppl to search the net in these circumstances... but guess what! i've been on it for an hour now, but to no avail... The only relevant thing i found on google was Topic 5775 of andreavb.. (Guess what! thas the no. of this topic!)

P.s.: For those who want a solution, i'll tell what i've tried:
1)Declared the datasource property as datasource (using the datasource typelibrary...
2)Tried seting the default  to NOTHING (in initializing and READ/WRITE properties...)
3) Left the default empty
4) Many other things i can't remember...

Doesnt seem oto work
        

____________________________
lOsT...

27-08-2005 at 03:35 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : ActiveX : ActiveX
Previous Topic (Component Request Pending)Next Topic (I try to use the MSHFlexGrid in Access) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder