Help!ComboBoxCellType

Posted by: caoweidehao on 8 September 2017, 12:56 pm EST

  • Posted 8 September 2017, 12:56 pm EST

    when combobox's selectedindex has been changed, i hope that next cell will be selected.
    just as spread for com  to the same. please help me.
    Public Class mycombo
    Inherits FarPoint.Win.Spread.CellType.ComboBoxCellType
    Dim WithEvents c As FarPoint.Win.FpCombo

    Public Overrides Function GetEditorControl(ByVal appearance As FarPoint.Win.Spread.Appearance, ByVal zoomFactor As Single) As System.Windows.Forms.Control
    c = CType(MyBase.GetEditorControl(appearance, zoomFactor), FarPoint.Win.FpCombo)
    Return c
    End Function

    Public Overrides Function
    IsReservedLocation(ByVal g As Graphics, ByVal x As Integer, ByVal y As Integer, ByVal rc As Rectangle, ByVal appearance As FarPoint.Win.Spread.Appearance, ByVal value As Object, ByVal zoomFactor As Single) As Object
    Dim
    rectButton As New Rectangle(rc.X + rc.Width - SystemInformation.VerticalScrollBarWidth, rc.Y, SystemInformation.VerticalScrollBarWidth, rc.Height)
    If rectButton.Contains(New Point(x, y)) Then
    Return Me
    Else
    Return Nothing
    End If
    End Function

    Private Sub
    c_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles c.KeyPress
    If c.Editable = False AndAlso c.SelectionLength = Len(c.Text) Then
    For
    i As Integer = 0 To c.List.Count - 1
    If CStr(c.List(i)).IndexOf(e.KeyChar) = 0 Then
    c.SelectedIndex = i
    c.SelectionStart = 0
    c.SelectionLength = Len(c.Text)
    e.Handled = True
    Exit For
    End If
    Next
    End If
    End Sub


    Private Sub
    c_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles c.SelectedIndexChanged
    Dim cSpread As FarPoint.Win.Spread.FpSpread
    cSpread = CType(c.Parent, FarPoint.Win.Spread.FpSpread)
    If Not cSpread Is Nothing Then
    Dim
    intRow As Integer = cSpread.ActiveSheet.ActiveRowIndex
    Dim intCol As Integer = cSpread.ActiveSheet.ActiveColumnIndex
    Dim intMaxCol As Integer = 0
    Dim intMaxRow As Integer = 0

    For i As Integer = cSpread.ActiveSheet.ColumnCount - 1 To 0 Step -1
    If cSpread.ActiveSheet.Columns(i).Visible Then
    intMaxCol = i
    Exit For
    End If
    Next

    For
    i As Integer = cSpread.ActiveSheet.RowCount - 1 To 0 Step -1
    If cSpread.ActiveSheet.Rows(i).Visible Then
    intMaxRow = i
    Exit For
    End If
    Next

    If
    intCol < intMaxCol Then
    intCol = intCol + 1
    ElseIf intRow < intMaxRow Then
    intRow = intRow + 1
    intCol = 0
    Else
    Exit Sub
    End If

    cSpread.ActiveSheet.SetActiveCell(intRow, intCol)
    End If
    End Sub

    End Class
     
  • Replied 8 September 2017, 12:56 pm EST

    Hello,


    This code is working for me. What issue(s) are you having with the code?

  • Replied 8 September 2017, 12:56 pm EST

    sorry,i means that if it have other more simplily solution to this question.(move to next cell ).


    Another question is

     when the combobox is diseditable

    how can the cell's selectionlenth is combobox's width but not text's length  .
  • Replied 8 September 2017, 12:56 pm EST

    Hello,


    1) There is not an easier way to implement this. You need to set the Active cell after selecting the item.


    2) If the Editable property is set to False, then the combobox celltype should act like a DropDownList instead of a Combobox and the selection should be the entire width of the cell and not just the text.

  • Replied 8 September 2017, 12:56 pm EST

    Thank you for your help

    but Dropdownlist only for web?


    I am in win's development.


     

  • Replied 8 September 2017, 12:56 pm EST

    Hello,


    No. A DropDownListBox is the same as a non editable Combobox. This could be Windows or Web.

  • Replied 8 September 2017, 12:56 pm EST

    For issue 1 I'm wondering why you're not simply catchign the ComboSelChange event and moving the active cell from there. There shouldn't be a need to override the celltype to do this.

  • Replied 8 September 2017, 12:56 pm EST

    i need that cell  leave to next cell  whenever the combobox's dropdownlist has been clicked .

  • Replied 8 September 2017, 12:56 pm EST

    I see.


    May be the version's problem 


    Thanks a lot.


     

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels