Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • Last Modified:

.NET - grid

In the Visual Studio .NET there is only one grid control, the DataGrid. Can this grid be used NOT binded to a database? (I mean, to add columns and rows, and write text in its cells?)

Or is there another grid control for .net available for free?

0
Azmodan
Asked:
Azmodan
1 Solution
 
iboutchkineCommented:
Yes you can use an unbound grid. here is an example


Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "
#End Region

    Private m_DataSet As DataSet
    Private m_dtFood As DataTable

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' Build the DataSet.
        m_DataSet = New DataSet()

        ' Build the States table.
        m_dtFood = New DataTable("Food")
        m_DataSet.Tables.Add(m_dtFood)

        Dim number_column As DataColumn
        number_column = New DataColumn("Number", GetType(Integer))
        number_column.AutoIncrement = True
        number_column.AutoIncrementSeed = 100
        number_column.AutoIncrementStep = 10
        m_dtFood.Columns.Add(number_column)

        m_dtFood.Columns.Add("Name", GetType(String))

        ' Populate the Food table.
        Dim food_data(1) As Object
        food_data(0) = Nothing
        food_data(1) = "Apple"
        m_dtFood.Rows.Add(food_data)

        food_data(1) = "Banana"
        m_dtFood.Rows.Add(food_data)

        food_data(1) = "Cherry"
        m_dtFood.Rows.Add(food_data)

        food_data(1) = "Date"
        m_dtFood.Rows.Add(food_data)

        food_data(1) = "Egg"
        m_dtFood.Rows.Add(food_data)

        food_data(1) = "Fig"
        m_dtFood.Rows.Add(food_data)

        ' Accept the data.
        m_DataSet.AcceptChanges()

        ' Attach the DataGrid to the DataTable.
        dgStates.DataSource = m_dtFood
    End Sub
End Class
0
 
AzmodanAuthor Commented:
This is a way of initialising the grid from a fake datasource, but is not used unbound.
So... i get that it can't be used unbound, and there isn;t another grid.. :(
0
 
DanRollinsCommented:
Hi Azmodan,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept iboutchkine's comment(s) as an answer.

Azmodan, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.
==========
DanRollins -- EE database cleanup volunteer
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now