cancel
Showing results for 
Search instead for 
Did you mean: 

adding a .net components on a b1 form

Former Member
0 Kudos

hi

i want to add a .net date time picker control to a b1 form which i m creating at run time. how can i do it. plz send code.

Thanks & Regards : Amit Kumar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Amit,

this will help you but once you open date time picker you can not access SBO untill you select something in datetime picker control.

Design a form with dateTimepicker Control(form size is equal to datetimepicker size)

add the below code under your button item pressed Event

newThread = New System.Threading.Thread(AddressOf DateTimePicker)

newThread .ApartmentState = Threading.ApartmentState.STA

newThread .Start()

newThread .Join()

Private Sub DateTimePicker()

Dim myForm As New frmDateTimePicker

strFileToOpen = ""

myForm.DateTimePicker1.Left = SAPBONEForm.Left - 100(SEt the properties relative to Where you want to show the control)

myForm.DateTimePicker1.BringToFront()

myForm.DateTimePicker1.Show()

myForm.ShowDialog()

DummyForm.DateTimePicker1.Select()

strDate = DummyForm.DateTimePicker1.Text

MsgBox(strDate )

System.Threading.Thread.CurrentThread.Abort()

End Sub

And close the win form once the user selects the date

Private Sub DateTimePicker1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DateTimePicker1.TextChanged

Me.Close()

End Sub

If it helps please reward the points

Regards

Vishnu

Former Member
0 Kudos

thnx vishnu. actually i want to add the dtp on the b1 form without using window form. and i found it myself.

thanks & regards: amit kumar

Former Member
0 Kudos

Hi Amit,

Can you post how you did it ?

Thanks!

Former Member
0 Kudos

hi jusi

add reference mscomctl2.dll form com components

then in ur project write code like this

using miccrosoft.visulbasic.comptability

private mscomctl2.dtpicker dt1;

// to add date time picker on the b1 form

sapbouicom.activex dtstart;

oItem = oForm.Items.Add("dtp_start", SAPbouiCOM.BoFormItemTypes.it_ACTIVE_X);

oItem.Left = 117;

oItem.Width = 82;

oItem.Top = 28;

oItem.Height = 18;

dtstart = ((SAPbouiCOM.ActiveX)(oItem.Specific));

dtstart.ClassID = "MSComCtl2.DTPicker.2";

dtp1 = ((MSComCtl2.DTPicker)(dtstart.Object));

oform.visible

if u got any probs then contact me.

regards: amit motla

Answers (0)