Results 1 to 4 of 4

Thread: [RESOLVED] Datagrid single line selection

  1. #1

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Resolved [RESOLVED] Datagrid single line selection

    I've been having troubles in doing single line selections in WM6.5 on DataGrid control, does anyone find a way to go around this problem?

    Thanks in advance
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  2. #2

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: Datagrid single line selection

    Anyone?
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  3. #3

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: Datagrid single line selection

    This code might be used in my other thread about datagrid ClearSelection.

    Finally i came across a possible answer, it's a very rude answer though, maybe someone will have a better idea for best performance at least.

    vb Code:
    1. Private Sub DataGridEntidades_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridEntidades.MouseUp
    2.         Try
    3.             Dim arrRows As ArrayList = CType(DataGridEntidades.GetType().GetField("m_rlrow", BindingFlags.NonPublic Or BindingFlags.Static Or BindingFlags.Instance).GetValue(DataGridEntidades), ArrayList)
    4.             Dim i As Integer
    5.             If DataGridEntidades.CurrentRowIndex >= 0 Then
    6.                 For i = 0 To arrRows.Count - 1 Step 1
    7.                     If i = DataGridEntidades.HitTest(e.X, e.Y).Row Then
    8.                         DataGridEntidades.CurrentRowIndex = i
    9.                         DataGridEntidades.Select(i)
    10.                     Else
    11.                         DataGridEntidades.UnSelect(i)
    12.                     End If
    13.                 Next
    14.                 Dim localPoint As New Point
    15.                 localPoint.X = MousePosition.X
    16.                 localPoint.Y = MousePosition.Y
    17.                 ContextMenu1.Show(Me, localPoint)
    18.             End If
    19.         Catch ex As Exception
    20.             '
    21.         End Try
    22.     End Sub

    I guess that this code won't need any explanations since it's a quite simple way to deselect rows. Hopefully someone will turbocharge this code

    Performance on:
    WM6.5 Professional
    Samsung Omnia I
    DataGrid using custom columns
    Using databinding with 3600 rows

    Time to unselect all rows, select only one row and show the ContextMenu, took not more then 0.4 secs
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  4. #4

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: [RESOLVED] Datagrid single line selection

    Other hidden properties that can be used as well

    Code:
    m_kcxDefaultColWidth, System.Int32
    m_kfDefaultVScrollVisible, System.Boolean
    m_kfDefaultHScrollVisible, System.Boolean
    m_kfDefaultColumnHeadersVisible, System.Boolean
    m_kfDefaultRowHeadersVisible, System.Boolean
    v_xyDpi, System.Int32
    v_cxDefaultWidth, System.Int32
    v_cyDefaultHeight, System.Int32
    v_cxyDefaultBorderWidth, System.Int32
    v_cxyDefaultGridLineWidth, System.Int32
    v_nDefaultTextInset, System.Int32
    v_cxyDefaultResizePixel, System.Int32
    v_cxDefaultRowHdrWidth, System.Int32
    v_cxAutoGenColWidth, System.Int32
    v_cxyMinRowColWidth, System.Int32
    m_renderer, System.Windows.Forms.GridRenderer
    m_tabstycol, System.Windows.Forms.GridTableStylesCollection
    m_tabstyActive, System.Windows.Forms.DataGridTableStyle
    m_objDataSource, System.Object
    m_cmData, System.Windows.Forms.CurrencyManager
    m_rlrow, System.Collections.ArrayList
    m_pdcolData, System.ComponentModel.PropertyDescriptorCollection
    m_fListHandlerActive, System.Boolean
    m_irowVisibleFirst, System.Int32
    m_irowVisibleLast, System.Int32
    m_crowVisible, System.Int32
    m_cyRow, System.Int32
    m_prefferedRowHeight, System.Int32
    m_fRowHeadersVis, System.Boolean
    m_icolVisibleFirst, System.Int32
    m_icolVisibleLast, System.Int32
    m_ccolVisible, System.Int32
    m_cyColumnHeader, System.Int32
    m_fColHeadersVis, System.Boolean
    m_fValidColsSet, System.Boolean
    m_icolValidFirst, System.Int32
    m_icolValidLast, System.Int32
    m_curcell, System.Windows.Forms.DataGridCurrentCell
    m_fColResizeActive, System.Boolean
    m_fRowResizeActive, System.Boolean
    m_irowcolResize, System.Int32
    m_xyResizeCur, System.Int32
    m_xyResizeLast, System.Int32
    m_xyResizeMax, System.Int32
    m_xyResizeMin, System.Int32
    m_fRowSelectDragActive, System.Boolean
    m_sbHorz, System.Windows.Forms.HScrollBar
    m_sbVert, System.Windows.Forms.VScrollBar
    m_yRenderLast, System.Int32
    m_xRenderLast, System.Int32
    CurrentCellChanged, System.EventHandler
    m_hwn, System.IntPtr
    m_gch, System.Runtime.InteropServices.GCHandle
    m_wnt, Microsoft.AGL.Forms.WNT
    m_thread, System.Threading.Thread
    m_mnucOwned, System.Windows.Forms.ContextMenu
    m_mnucFloating, System.Windows.Forms.ContextMenu
    m_qutaskInvoke, System.Collections.Queue
    m_dataBindings, System.Windows.Forms.ControlBindingsCollection
    m_bindingContext, System.Windows.Forms.BindingContext
    m_fDisposed, System.Boolean
    m_fCalledDispose, System.Boolean
    m_fDestroyed, System.Boolean
    m_fEnabledReal, System.Boolean
    m_objTag, System.Object
    m_strName, System.String
    m_cLayoutSuspend, System.Int32
    m_fScrollableSav, System.Boolean
    m_fMousePressed, System.Boolean
    m_fFocusAttempt, System.Boolean
    m_fSkipValidation, System.Boolean
    m_bsRequiredScaling, System.Windows.Forms.BoundsSpecified
    m_cSuspendValidation, System.Int16
    m_fParentedOrOwned, System.Boolean
    m_context, System.Windows.Forms.ApplicationThreadContext
    m_rlctlChildren, System.Collections.ArrayList
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width