cancel
Showing results for 
Search instead for 
Did you mean: 

SAPLogoncontrol in C#.net

Former Member
0 Kudos

what is the counterpart of SAPLogoncontrol in VB( from ocx) in SAP.Net Connector? I am trying to display a login form in a windows application constructed using c#, similar to what can be done in VB using SAPLogoncontrol...

thanks...

Accepted Solutions (0)

Answers (1)

Answers (1)

reiner_hille-doering
Active Contributor
0 Kudos

There is no pre-defined Logon Control for NCo, but it's terribly simple to create one on your own: If you only need some parameters, create a form, drop a Destination or SAPLogonDestination and some TextBoxes and databind the needed properties of the destination with the TextBoxes.

If you need a full-featured Logon Control, you best use a CombinedDestination and a DataGrid control. This is what we use internally to add a new SAP server to Server Explorer.

reiner_hille-doering
Active Contributor
0 Kudos

Here is the sample Logon Control in VB (you could of cause have the same in C# as well):

Public Class SAPLogonForm

Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Friend WithEvents PropertyGrid1 As System.Windows.Forms.PropertyGrid

Friend CombinedDestination1 As SAP.Connector.CombinedDestination

Friend WithEvents OkButton As System.Windows.Forms.Button

Friend WithEvents CancelButton As System.Windows.Forms.Button

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

Me.PropertyGrid1 = New System.Windows.Forms.PropertyGrid

Me.CombinedDestination1 = New SAP.Connector.CombinedDestination

Me.OkButton = New System.Windows.Forms.Button

Me.CancelButton = New System.Windows.Forms.Button

Me.SuspendLayout()

'

'PropertyGrid1

'

Me.PropertyGrid1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _

Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)

Me.PropertyGrid1.CommandsVisibleIfAvailable = True

Me.PropertyGrid1.LargeButtons = False

Me.PropertyGrid1.LineColor = System.Drawing.SystemColors.ScrollBar

Me.PropertyGrid1.Location = New System.Drawing.Point(0, 0)

Me.PropertyGrid1.Name = "PropertyGrid1"

Me.PropertyGrid1.PropertySort = System.Windows.Forms.PropertySort.Categorized

Me.PropertyGrid1.SelectedObject = Me.CombinedDestination1

Me.PropertyGrid1.Size = New System.Drawing.Size(292, 266)

Me.PropertyGrid1.TabIndex = 0

Me.PropertyGrid1.Text = "PropertyGrid1"

Me.PropertyGrid1.ToolbarVisible = False

Me.PropertyGrid1.ViewBackColor = System.Drawing.SystemColors.Window

Me.PropertyGrid1.ViewForeColor = System.Drawing.SystemColors.WindowText

'

'CombinedDestination1

'

' Me.CombinedDestination1.DestinationType = GetType(SAP.Connector.SAPLogonDestination)

'

'OkButton

'

Me.OkButton.DialogResult = System.Windows.Forms.DialogResult.OK

Me.OkButton.Location = New System.Drawing.Point(24, 280)

Me.OkButton.Name = "OkButton"

Me.OkButton.TabIndex = 1

Me.OkButton.Text = "Ok"

'

'CancelButton

'

Me.CancelButton.CausesValidation = False

Me.CancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel

Me.CancelButton.Location = New System.Drawing.Point(152, 280)

Me.CancelButton.Name = "CancelButton"

Me.CancelButton.TabIndex = 1

Me.CancelButton.Text = "Cancel"

'

'SAPLogonForm

'

Me.AcceptButton = Me.OkButton

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(292, 334)

Me.Controls.Add(Me.OkButton)

Me.Controls.Add(Me.PropertyGrid1)

Me.Controls.Add(Me.CancelButton)

Me.Name = "SAPLogonForm"

Me.Text = "SAPLogonForm"

Me.ResumeLayout(False)

End Sub

#End Region

Private Sub PropertyGrid1_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles PropertyGrid1.Validating

Dim testConnection As SAP.Connector.Connection

testConnection = SAP.Connector.Connection.GetNewConnection(Me.CombinedDestination1.Internal)

Try

testConnection.Open()

Catch

e.Cancel = True

Finally

testConnection.Dispose()

End Try

End Sub

Private Sub OkButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles OkButton.Click

End Sub

End Class