Public Class mySubEd
Inherits Form
Implements FarPoint.Win.Spread.CellType.ISubEditor
Public Event CloseUp(ByVal sender As Object, ByVal e As EventArgs) Implements FarPoint.Win.Spread.CellType.ISubEditor.CloseUp
Public Event ValueChanged(ByVal sender As Object, ByVal e As EventArgs) Implements FarPoint.Win.Spread.CellType.ISubEditor.ValueChanged
Private BtnOk As Button = Nothing
Private BtnCancel As Button = Nothing
Private txt As TextBox = Nothing
Public Sub New()
FormBorderStyle = FormBorderStyle.FixedSingle
MaximizeBox = False
MinimizeBox = False
ControlBox = False
txt = New TextBox
BtnOk = New Button
BtnCancel = New Button
txt.Location = New Point(0, 0)
txt.Size = New Size(110, 200)
txt.ForeColor = Color.Red
BtnOk.Location = New Point(3, 75)
BtnOk.Size = New Size(50, 25)
BtnOk.Text = "OK"
BtnOk.ForeColor = Color.Red
BtnCancel.Location = New Point(57, 75)
BtnCancel.Size = New Size(50, 25)
BtnCancel.Text = "Cancel"
BtnCancel.ForeColor = Color.Red
Controls.Add(txt)
Controls.Add(BtnOk)
Controls.Add(BtnCancel)
Text = "Editor"
AddHandler BtnOk.Click, AddressOf OKClicked
AddHandler BtnCancel.Click, AddressOf CloseClicked
AddHandler txt.TextChanged, AddressOf txtTextChanged
End Sub
Private Sub OKClicked(ByVal sender As Object, ByVal e As EventArgs)
RaiseEvent ValueChanged(Me, EventArgs.Empty)
RaiseEvent CloseUp(Me, EventArgs.Empty)
End Sub
Private Sub CloseClicked(ByVal sender As Object, ByVal e As EventArgs)
RaiseEvent CloseUp(Me, EventArgs.Empty)
End Sub
Private Sub txtTextChanged(ByVal sender As Object, ByVal e As EventArgs)
Text = txt.Text
End Sub
Public Function GetLocation(ByVal rect As Rectangle) As Point Implements FarPoint.Win.Spread.CellType.ISubEditor.GetLocation
Dim pt As New Point(0)
Dim sz As Size = GetPreferredSize()
pt.Y = (Screen.PrimaryScreen.WorkingArea.Height / 2) - (sz.Height / 2)
pt.X = (Screen.PrimaryScreen.WorkingArea.Width / 2) - (sz.Width / 2)
Return pt
End Function
Public Function GetPreferredSize() As Size Implements FarPoint.Win.Spread.CellType.ISubEditor.GetPreferredSize
Return New Size(115, 130)
End Function
Public Function GetSubEditorControl() As Control Implements FarPoint.Win.Spread.CellType.ISubEditor.GetSubEditorControl
Return Me
End Function
Public Function GetValue() As Object Implements FarPoint.Win.Spread.CellType.ISubEditor.GetValue
Return txt.Text
End Function
Public Sub SetValue(ByVal value As Object) Implements FarPoint.Win.Spread.CellType.ISubEditor.SetValue
value = txt.Text
End Sub
End Class
Private Sub Form1Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim t As New FarPoint.Win.Spread.CellType.TextCellType
t.SubEditor = New mySubEd
FpSpread1.ActiveSheet.Cells(0, 0).CellType = t
End Sub
Private Sub FpSpread1SubEditorOpen(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.SubEditorOpeningEventArgs) Handles
FpSpread1.SubEditorOpen
TextBox1.Text = e.View.ToString()
End Sub