Home Forums WinForms controls Xceed Grid for WinForms Error occured when column header click

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

    Hi

     

    I have used following code sample to bind the data able to
    the grid.

    GridControl1.BeginInit()

    GridControl1.DataSource =
    ds.Tables(0).DefaultView

    GridControl1.ValueMember = “OrganizationID”

    Dim cell As Xceed.Grid.DataCell

     For Each cell In
    GridControl1.DataRowTemplate.Cells

          AddHandler
    cell.DoubleClick, AddressOf Me.cell_DoubleClick

          AddHandler
    cell.MouseDown, AddressOf Me.cell_MouseDown

          AddHandler
    cell.KeyDown, AddressOf Me.cell_KeyDown

          AddHandler
    cell.Click, AddressOf Me.SelectedValueCahnge

      Next cell

      For Each col As
    Xceed.Grid.Column In GridControl1.Columns

          AddHandler
    col.WidthChanged, AddressOf Me.cell_WidthChange

      Next col

    AddHandler
    GridControl1.Resize, AddressOf Me.grid_Resize

    AddHandler
    GridControl1.DataRowTemplate.Cells(“CountryID”).ValueChanged,
    AddressOf Me.FormatCountryColumn

    AddHandler GridControl1.DataRowTemplate.Cells(“VisitCountryID”).ValueChanged,
    AddressOf Me.FormatCountryColumn

     

    GridControl1.EndInit()

     

    FormatCountryColumn is used to replace the
    country ID using the Country name.

    Private Sub FormatCountryColumn(ByVal
    sender As Object,
    ByVal e As
    System.EventArgs)

        If TypeOf (sender) Is
    Xceed.Grid.DataCell Then

           Dim cell
    As Xceed.Grid.DataCell = CType(sender, Xceed.Grid.DataCell)

           If Not cell.Value Is
    DBNull.Value AndAlso Not
    cell.Value = “” Then

             cell.Value =
    m_oCountry.GetCountryName(Convert.ToString(cell.Value))

           End If

        End If

    End Sub

     

    In the first time grid load code is
    successfully run.

    But when I click the “Country”
    column header it raise the following error.

    When I disable the column header
    sorting facility using ,

    .Columns(“CountryID”).CanBeSorted
    = False then error is not raised.

    But column header sorting is a
    requirement.

    Can you please help to resolve this?

     

    Here is the error details

     Message:The index must be greater than or equal to 0 and less than Count.
    Parameter name: index
    Actual value was 0.
    Source:Xceed.Editors
    Stack Trace:   at Xceed.Utils.Exceptions.ThrowException.ThrowArgumentOutOfRangeException(String paramName, Object value, String message)
       at Xceed.Utils.Collections.ListBase.ListGetItem(Int32 index)
       at Xceed.Grid.Collections.VisibleRowList.get_Item(Int32 index)
       at Xceed.Grid.PaintManager.CalculateBodyVisibleRows(Graphics graphics, Rectangle& gridRectangle)
       at Xceed.Grid.PaintManager.Update()
       at Xceed.Grid.PaintManager.GetVisibleRowFromRow(Row row)
       at Xceed.Grid.PaintManager.GetVisibleCellFromCell(Cell cell)
       at Xceed.Grid.PaintManager.GetVisualElementClientPosition(VisualGridElement element)
       at Xceed.Grid.VisualGridElement.get_ClientPosition()
       at Xceed.Grid.VisualGridElement.GridPointToClient(Point point)
       at Xceed.Grid.GridControl.DoMouseUp(MouseEventArgs e)
       at Xceed.Grid.GridControl.OnMouseUp(MouseEventArgs e)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at Xceed.Grid.GridControl.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

     

    Also I have notice that when I
    change the country ID to Country name “
    FormatCountryColumn”
    function is executed again. ( I think event is fired again).

     

    Imported from legacy forums. Posted by Tharaka (had 809 views)

    Xceed Support
    Member
    Post count: 5658

    We are handling this issue through e-mail with the customer.

    Imported from legacy forums. Posted by CharlesB (had 1096 views)

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