DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Fri, 20 Jul 2007 17:11:11 -0000,    posted on: microsoft.public.dotnet.framework.compactframework        back       

Thread Index
  1    Tim Frawley


Datagrid refresh problem with new entries   
In the application I am writing I open a dialog window for entry of
value pairs via combobox selections that are added to a grid on that
form.  The items in the grid can be removed as well.  The problem I am
having is when the window is closed and then re-opened an added item
row doesn't appear in the grid.  If the window is closed and re-opened
the new row will appear.

Here is code from the Form Load event:

        Dim tableStyle As New DataGridTableStyle
        tableStyle.MappingName = "sample_area"

        Dim column As New DataGridTextBoxColumn
        column.MappingName = "district"
        column.HeaderText = "District"
        column.Width = 100
        tableStyle.GridColumnStyles.Add(column)

        column = New DataGridTextBoxColumn
        column.MappingName = "subdistrict"
        column.HeaderText = "SubDistrict"
        column.Width = 100
        tableStyle.GridColumnStyles.Add(column)

        tableStyle.MappingName = "sample_area"

        With grdAreas
            .ColumnHeadersVisible = True
            .TableStyles.Add(tableStyle)
        End With

        grdAreas.DataSource = gdsData.Tables("sample_area")

The Add Event:

        Dim dr As System.Data.DataRow
        dr = gdsData.Tables("sample_area").NewRow
        dr.Item("year") = gstrCWTYear
        dr.Item("sample") = gstrSampleNumber
        dr.Item("district") = cboDistrict.Text
        dr.Item("subdistrict") = cboSubdistrict.Text
        gdsData.Tables("sample_area").Rows.Add(dr)

In the remove event I find the row in the dataset and issue a

        gdsData.Tables("sample_area").Rows(rowIndex).Delete

The very first time the window is opened everything seems to work fine
but if the window is closed:

    Private Sub btnOk_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnOk.Click
        Me.Close()
    End Sub

And then opened:

            Dim f As New frmArea
            f.ShowDialog()

The grid will not display a new "addition".

I have tried refresh but the only thing that seems to work is setting
the datasource of the grid to nothing and then  set it back to the
dataset's datatable.  This; however, just doesn't seem right.

Does anyone have any idea what I am doing wrong?
Date:Fri, 20 Jul 2007 17:11:11 -0000   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us