Home Forums WinForms controls Xceed Grid for WinForms the cell event ?

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #13325 |

    1. I click the mouse,the cell_click is useful.when i move the right button and left button on the keyboard,the cell’focus is moving, but that can’t delegate the event.
    what does the event when i move the (<- ) and (-> ) buttons on the cell ??

    2. When i input the data into the cell,the grid refresh.
    Can it hold on the cell which i input the data before ?

    Imported from legacy forums. Posted by michaelcao (had 6285 views)

    User (Old forums)
    Member
    Post count: 23064

    1. I don’t think the Cell class has an event for getting or losing focus. But the GridControl class has some events you can use for this:
    – <b>CurrentRowChanged</b>: the current row has changed (focus moved to other row)
    – <b>CurrentColumnChanged</b>: the current column has changed (focus moved to other column)
    – <b>CurrentCellChanged</b>: the current cell has changed (focus moved to other cell)

    2. I don’t understand what you mean. English is not my primary language. Could you explain it?

    Imported from legacy forums. Posted by Tommy (had 755 views)

    User (Old forums)
    Member
    Post count: 23064

    Tommy,
    Thanks for your prompt response. Acturally, my English is poor as well, therefore, I just want to ask you that – how can I manipulate the data on Xceed GRID without the help of mouse (ie. only use keyboard). Please help me to solve the problem, thanks a lot.

    Another question is, whenever I update the data of a cell, after updating, the focus shift to the initial position of the GRID, so, how can I make the focus stay in the same place instead of shifting away? I can send you some pictures to illustrate my question, could you give me your email address if available? Thanks again.

    fux168@yahoo.com.tw

    Imported from legacy forums. Posted by michaelcao (had 357 views)

    User (Old forums)
    Member
    Post count: 23064

    Manipulating the data with the keyboard: you can press the <b>F2</b> key to edit a cell value. When editing a cell, you can press <b>Enter</b> to confirm fill in the value in the cell, or <b>Esc</b> to cancel the editing.

    About the shifting of the focus: before the update, you should store the index of the row and column of the current cell in 2 variables, and after the update, you should set the current cell back, like this:
    <code>// before update:
    int rowIndex, columnIndex;
    if (grid.CurrentRow is Xceed.Grid.DataRow) rowIndex = grid.DataRows.IndexOf((Xceed.Grid.DataRow)grid.CurrentRow);
    else rowIndex = -1;
    columnIndex = grid.CurrentColumn.Index;

    // after update:
    if (rowIndex >= 0 && rowIndex < grid.DataRows.Count) grid.CurrentRow = grid.DataRows[rowIndex];
    if (columnIndex >= 0 && columnIndex < grid.Columns.Count) grid.CurrentColumn = grid.Columns[columnIndex];

    Imported from legacy forums. Posted by Tommy (had 270 views)

    User (Old forums)
    Member
    Post count: 23064

    thank a lot ! I appreciate your favor

    but i try later ..

    1.
    GridControl1.BeginInit()
    GridControl1.DataSource = db.Tables(0)
    Dim i As Integer
    For i = 2 To GridControl1.DataRowTemplate.Cells.Count – 1
    AddHandler GridControl1.DataRowTemplate.Cells(i).Click, AddressOf Me.cell_Click
    Next
    GridControl1.EndInit()

    ***** AddHandler GridControl1.DataRowTemplate.Cells(i).<the event can be happen by user put som buttons on keyboard ??> , AddressOf Me.cell_Click *******

    2.
    <code>// before update :

    ‘==== find the position===== GridControl1 is Xeed.GridControl
    Dim rowIndex, columnIndex As Integer
    rowIndex = Me.GridControl1.DataRows.IndexOf(Me.GridControl1.CurrentRow)
    columnIndex = Me.GridControl1.Columns.IndexOf(Me.GridControl1.CurrentColumn)

    ‘example: i get the rowIndex = 2 and columnIndex = 50

    GridControl1.Refresh()
    Call Query() ‘load the data and display the data on Xceed.GridControl1

    Me.GridControl1.CurrentRow = Me.GridControl1.DataRows(rowIndex)
    Me.GridControl1.CurrentColumn = Me.GridControl1.Columns(columnIndex)
    Me.GridControl1.Select()

    run later ====> the selected row which color be change still is first row

    Imported from legacy forums. Posted by michaelcao (had 452 views)

    User (Old forums)
    Member
    Post count: 23064

    1. If you want to catch key events, you will have to catch them from GridControl, and not from Cell.
    <code>AddHandler GridControl1.KeyDown, AddressOf Me.GridControl1_KeyDown
    Private Sub GridControl1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
    Dim cell As Xceed.Grid.Cell = GridControl1.CurrentCell
    ‘ do something with cell
    End Sub</code>
    2. Add this before Me.GridControl1.Select():
    <code>Me.GridControl1.SelectedRows.Clear()
    Me.GridControl1.SelectedRows.Add(Me.GridControl1.CurrentRow)</code>

    Imported from legacy forums. Posted by Tommy (had 198 views)

    User (Old forums)
    Member
    Post count: 23064

    nice advice !

    Me.GridControl1.CurrentRow = Me.GridControl1.DataRows(rowIndex)
    Me.GridControl1.CurrentColumn = Me.GridControl1.Columns(columnIndex)

    Me.GridControl1.SelectedRows.Clear()
    Me.GridControl1.SelectedRows.Add(Me.GridControl1.CurrentRow)

    Me.GridControl1.Select()

    but if in the beginning :
    rowIndex = 100
    columnIndex = 100

    the selected color row is out of Xceed’range , i cannt see the color row ?

    thanks from Taiwan!

    Imported from legacy forums. Posted by michaelcao (had 459 views)

    User (Old forums)
    Member
    Post count: 23064

    Just before Me.GridControl1.Select():<code>Me.GridControl1.CurrentRow.BringIntoView()</code>
    You’re welcome, from Belgium!

    Imported from legacy forums. Posted by Tommy (had 194 views)

    User (Old forums)
    Member
    Post count: 23064

    ——————————————————————————————-
    if in the beginning I fix the column
    ——————————————————————————————-
    Dim c1 As FixedColumn = New FixedColumn(GridControl1.Columns(0), GridControl1.Columns(0).VisibleIndex)
    Dim c2 As FixedColumn = New FixedColumn(GridControl1.Columns(1), GridControl1.Columns(0).VisibleIndex)

    m_collection.Add(c1)
    m_collection.Add(c2)

    //…..code….

    Me.GridControl1.DataRows(rowIndex).Cells(columnIndex).BringIntoView()

    I try case1: Me.GridControl1.Scroll(ScrollDirection.RightmostPage) ==> fail
    case2: Me.GridControl1.FirstVisibleColumn = Me.GridControl1.Columns(columnIndex)
    =====> still fail

    Me.GridControl1.Select()

    ——————————————————————————————-
    the display on the xeed grid
    ++++++++++++++++++++++++++++++++++++
    ( i can see scope )( i cant see X ) <== datarow A
    ++++++++++++++++++++++++++++++++++++
    ps: 1. I update the cell X
    2. ( ) <=== can see xeed grid view
    ——————————————————————————————-

    ?? I still can not see the right cell ? ?

    When i use BringIntoView() method , i discover a strange thing .
    That is the cell is in the view but the position is not the same before!?
    ( Sort again but position change ?)

    English is poor ,pardon me !
    thank you ..

    00:52 will sleep …

    Imported from legacy forums. Posted by michaelcao (had 405 views)

    User (Old forums)
    Member
    Post count: 23064

    Me.GridControl1.DataRows(rowIndex).Cells(columnIndex).BringIntoView()

    Me.GridControl1.FirstVisibleColumn = Me.GridControl1.Columns(columnIndex)
    Me.GridControl1.Select()

    —————————– I use a little fool method ——————————–
    If columnIndex > 25 Then
    Me.GridControl1.Scroll(ScrollDirection.PageRight)
    Me.GridControl1.Scroll(ScrollDirection.PageRight)
    Me.GridControl1.Scroll(ScrollDirection.PageRight)
    ElseIf columnIndex < 5 Then
    Me.GridControl1.Scroll(ScrollDirection.PageLeft)
    Me.GridControl1.Scroll(ScrollDirection.PageLeft)
    Me.GridControl1.Scroll(ScrollDirection.PageLeft)
    End If

    ——————————————————————————————-

    Imported from legacy forums. Posted by michaelcao (had 7207 views)

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.