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

addnewrow not showing on formload

6 Answers 133 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Emilio
Top achievements
Rank 1
Emilio asked on 08 May 2012, 04:10 AM
Hi,

allowaddnew row was set to true, on form load there's blank row in the grid but the "click here to add new row" was not shown, but when i clicked a column the text shows.  how can i show this message on form load?


Thanks,

6 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 08 May 2012, 12:18 PM
Hello, 

I can't replicate this issue. Please try the following. 
1: Drop a RadGridView onto a form. 
2: Add the following code

Public Class User
    Public Sub New(id__1 As Integer, name__2 As String)
        Id = id__1
        Name = name__2
    End Sub
 
    Public Sub New()
    End Sub
 
    Public Property Id() As Integer
        Get
            Return m_Id
        End Get
        Set(value As Integer)
            m_Id = Value
        End Set
    End Property
    Private m_Id As Integer
 
    Public Property Name() As String
        Get
            Return m_Name
        End Get
        Set(value As String)
            m_Name = Value
        End Set
    End Property
    Private m_Name As String
 
End Class

In form load
Me.RadGridView1.AddNewRowPosition = SystemRowPosition.Top
Me.RadGridView1.AllowAddNewRow = True
Dim list As New List(Of User)()
For i = 0 To 10
    list.Add(New User(i, "Name " & i.ToString()))
Next
Me.RadGridView1.DataSource = list

Hope that helps
Richard
0
Emilio
Top achievements
Rank 1
answered on 08 May 2012, 01:26 PM
Hi,

in my form load, there's no data yet in the grid, we noticed that if we populate the data on formload, there's no problem.

Thanks
0
Richard Slade
Top achievements
Rank 2
answered on 08 May 2012, 01:31 PM
That's correct. When there is no data, and the grid is unbound, then the grid will be blank. 
Please remember to mark as answer
Thanks
Richard
0
Emilio
Top achievements
Rank 1
answered on 08 May 2012, 02:31 PM
Hi Richard,

The grid was bound, just so happen that the table was empty, the blank row is no problem, but the text "Click here to add new row" does not appear until we click the column header, is there a way we could show it if initially the table is empty.

please see attached file .

Thank you and best regards,
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 08 May 2012, 02:50 PM
Hello, 

After setting your datasource, set the following

C#
this.radGridView1.CurrentRow = null;

VB
Me.RadGridView1.CurrentRow = Nothing

Richard
0
Emilio
Top achievements
Rank 1
answered on 08 May 2012, 03:01 PM
Great help.

Thanks. and more power.
Tags
GridView
Asked by
Emilio
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Emilio
Top achievements
Rank 1
Share this question
or