This is a migrated thread and some comments may be shown as answers.

GridView is insane

3 Answers 162 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Basel Nimer
Top achievements
Rank 2
Basel Nimer asked on 17 Apr 2010, 01:56 PM
I spent 3 hours trying to figure this out, i am sure it is something silly, but no matter what i try i am still stuck


why the button is not deleting the item in the grid?!!!

see code:

Form1.Designer.vb
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ 
Partial Class Form1 
    Inherits System.Windows.Forms.Form 
 
    'Form overrides dispose to clean up the component list. 
    <System.Diagnostics.DebuggerNonUserCode()> _ 
    Protected Overrides Sub Dispose(ByVal disposing As Boolean
        Try 
            If disposing AndAlso components IsNot Nothing Then 
                components.Dispose() 
            End If 
        Finally 
            MyBase.Dispose(disposing) 
        End Try 
    End Sub 
 
    'Required by the Windows Form Designer 
    Private components As System.ComponentModel.IContainer 
 
    'NOTE: The following procedure is required by the Windows Form Designer 
    'It can be modified using the Windows Form Designer.   
    'Do not modify it using the code editor. 
    <System.Diagnostics.DebuggerStepThrough()> _ 
    Private Sub InitializeComponent() 
        Me.RadGridView1 = New Telerik.WinControls.UI.RadGridView 
        Me.RadButton1 = New Telerik.WinControls.UI.RadButton 
        CType(Me.RadGridView1, System.ComponentModel.ISupportInitialize).BeginInit() 
        CType(Me.RadGridView1.MasterGridViewTemplate, System.ComponentModel.ISupportInitialize).BeginInit() 
        CType(Me.RadButton1, System.ComponentModel.ISupportInitialize).BeginInit() 
        Me.SuspendLayout() 
        ' 
        'RadGridView1 
        ' 
        Me.RadGridView1.Location = New System.Drawing.Point(0, 0) 
        Me.RadGridView1.Name = "RadGridView1" 
        Me.RadGridView1.Size = New System.Drawing.Size(240, 150) 
        Me.RadGridView1.TabIndex = 0 
        ' 
        'RadButton1 
        ' 
        Me.RadButton1.AllowShowFocusCues = True 
        Me.RadButton1.Location = New System.Drawing.Point(12, 213) 
        Me.RadButton1.Name = "RadButton1" 
        Me.RadButton1.Size = New System.Drawing.Size(75, 23) 
        Me.RadButton1.TabIndex = 1 
        Me.RadButton1.Text = "RadButton1" 
        ' 
        'Form1 
        ' 
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) 
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font 
        Me.ClientSize = New System.Drawing.Size(284, 262) 
        Me.Controls.Add(Me.RadButton1) 
        Me.Controls.Add(Me.RadGridView1) 
        Me.Name = "Form1" 
        Me.Text = "Form1" 
        CType(Me.RadGridView1.MasterGridViewTemplate, System.ComponentModel.ISupportInitialize).EndInit() 
        CType(Me.RadGridView1, System.ComponentModel.ISupportInitialize).EndInit() 
        CType(Me.RadButton1, System.ComponentModel.ISupportInitialize).EndInit() 
        Me.ResumeLayout(False
        Me.PerformLayout() 
 
    End Sub 
    Friend WithEvents RadGridView1 As Telerik.WinControls.UI.RadGridView 
    Friend WithEvents RadButton1 As Telerik.WinControls.UI.RadButton 
End Class 
 


Form1.vb
Imports Telerik.WinControls 
Public Class Form1 
    Private ModuleName As String = "Form1" 
    Private list As New ArrayList() 
 
    Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load 
        AddColumns() 
        FillDevelopmentItem() 
    End Sub 
    Private Sub FillDevelopmentItem() 
 
        list.Add(New RGItem(1, False"Development Fees", 1, 0.75D)) 
        list.Add(New RGItem(2, True"15x18", 4, 5.75D)) 
        RadGridView1.DataSource = list 
    End Sub 
    Private Sub AddColumns() 
        Dim xCol As UI.GridViewDataColumn 
        With RadGridView1 
            .MasterGridViewTemplate.AllowAddNewRow = False 
            .DataSource = Nothing 
            .GridElement.BeginUpdate() 
 
            .MasterGridViewTemplate.Columns.Clear() 
            xCol = New UI.GridViewTextBoxColumn("ID""P_DP_Detail_ID"
            xCol.VisibleInColumnChooser = False 
            xCol.IsVisible = False 
            xCol.AllowSort = False 
            xCol.AllowResize = False 
            .MasterGridViewTemplate.Columns.Add(xCol) 
 
            'xCol = New UI.GridViewCommandColumn("Delete", "ShowDel") 
            xCol = New UI.GridViewDataColumn("Delete""ShowDel"
            xCol.VisibleInColumnChooser = False 
            xCol.IsVisible = True 
            xCol.AllowSort = False 
            xCol.AllowResize = False 
            .MasterGridViewTemplate.Columns.Add(xCol) 
 
            xCol = New UI.GridViewTextBoxColumn("Description""MeasureDescription"
            xCol.VisibleInColumnChooser = False 
            xCol.IsVisible = True 
            xCol.AllowSort = False 
            xCol.AllowResize = False 
            .MasterGridViewTemplate.Columns.Add(xCol) 
 
            xCol = New UI.GridViewDecimalColumn("Count""P_DP_Detail_Count"
            xCol.VisibleInColumnChooser = False 
            xCol.IsVisible = True 
            xCol.AllowSort = False 
            xCol.AllowResize = False 
            .MasterGridViewTemplate.Columns.Add(xCol) 
 
            xCol = New UI.GridViewDecimalColumn("Total""TotalAmount"
            xCol.VisibleInColumnChooser = False 
            xCol.IsVisible = True 
            xCol.AllowSort = False 
            xCol.AllowResize = False 
            .MasterGridViewTemplate.Columns.Add(xCol) 
 
            '.Columns(GridCols.enDesc).Width = 220 
            '.Columns(GridCols.enCount).Width = 150 
            '.Columns(GridCols.enTotal).Width = 150 
 
            .GridElement.EndUpdate() 
        End With 
      
    End Sub 
    Private Class RGItem 
        Private _P_DP_Detail_ID As Integer = 0 
        Private _ShowDel As Boolean = True 
        Private _MeasureDescription As String = String.Empty 
        Private _P_DP_Detail_Count As Integer = 1 
        Private _TotalAmount As Decimal = 0D 
        Private _Notes As String = String.Empty 
 
        Public Property P_DP_Detail_ID() As Integer 
            Get 
                Return _P_DP_Detail_ID 
            End Get 
            Set(ByVal value As Integer
                _P_DP_Detail_ID = value 
            End Set 
        End Property 
 
        Public Property ShowDel() As Boolean 
            Get 
                Return _ShowDel 
            End Get 
            Set(ByVal value As Boolean
                _ShowDel = value 
            End Set 
        End Property 
 
        Public Property MeasureDescription() As String 
            Get 
                Return _MeasureDescription 
            End Get 
            Set(ByVal value As String
                _MeasureDescription = value 
            End Set 
        End Property 
 
        Public Property P_DP_Detail_Count() As Integer 
            Get 
                Return _P_DP_Detail_Count 
            End Get 
            Set(ByVal value As Integer
                _P_DP_Detail_Count = value 
            End Set 
        End Property 
 
        Public Property TotalAmount() As Decimal 
            Get 
                Return _TotalAmount 
            End Get 
            Set(ByVal value As Decimal
                _TotalAmount = value 
            End Set 
        End Property 
 
        Public Property Notes() As String 
            Get 
                Return _Notes 
            End Get 
            Set(ByVal value As String
                _Notes = value 
            End Set 
        End Property 
 
        Public Sub New(ByVal iID As IntegerByVal iShowDel As BooleanByVal iMeasureDescription As StringByVal iCount As IntegerByVal iTotal As Decimal
            P_DP_Detail_ID = iID 
            ShowDel = iShowDel 
            MeasureDescription = iMeasureDescription 
            P_DP_Detail_Count = iCount 
            TotalAmount = iTotal 
        End Sub 
    End Class 
 
    Private Sub RadButton1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles RadButton1.Click 
        RadGridView1.Rows.RemoveAt(0) 
    End Sub 
End Class 
 

3 Answers, 1 is accepted

Sort by
0
Accepted
Versile
Top achievements
Rank 1
answered on 19 Apr 2010, 07:50 AM
the grid is bound to your arraylist, just delete the item from the arraylist
0
Basel Nimer
Top achievements
Rank 2
answered on 20 Apr 2010, 07:36 AM
I used a custom binding list,

BUT, when i delete a row, it deletes automaticlly from it, why this didnt happen with the arraylist?
0
Julian Benkov
Telerik team
answered on 21 Apr 2010, 02:18 PM
If your binding list object implements the IBindingList interface the RadGridView control will refresh automatically. The ArrayList, List will not implement this interface and will not support notification events. The IBindingList interface is required for all list controls which have binding support. More information you can find in MSDN.
 

Sincerely yours,

Julian Benkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Basel Nimer
Top achievements
Rank 2
Answers by
Versile
Top achievements
Rank 1
Basel Nimer
Top achievements
Rank 2
Julian Benkov
Telerik team
Share this question
or