Datagrid not updating problem.

S

Scott Meddows

I have a datagrid control that I've inherited from the base datagrid control (Source below).

I am applying a datatable style onto the datatable that I assign as my datasource.

All of my column but one are set as readonly=true. The writeable column does not update when I'm editing it. Is there something
different that I need to be doing to update this data? Also, how do I get the "new row" to not appear at the bottom of the
datagrid?

Thanks

Scott

-=-=-=-=-=-=-=-=- Source -=-=-=-=-=-=-=-=-

Public Class MyDataGrid
Inherits DataGrid

Public Event MyVScroll As ScrollEventHandler
Public Event MyHScroll As ScrollEventHandler

Protected Overrides Sub GridVScrolled(ByVal sender As Object, ByVal e As ScrollEventArgs)
MyBase.GridVScrolled(Me, e)
OnMyVScroll(e)
End Sub

Protected Overrides Sub GridHScrolled(ByVal sender As Object, ByVal e As ScrollEventArgs)
MyBase.GridHScrolled(sender, e)
OnMyHScroll(e)
End Sub

Protected Sub OnMyVScroll(ByVal e As ScrollEventArgs)
RaiseEvent MyVScroll(Me, e)
End Sub

Protected Sub OnMyHScroll(ByVal e As ScrollEventArgs)
RaiseEvent MyHScroll(Me, e)
End Sub

Public Sub SynVScroll(ByVal e As ScrollEventArgs)
MyBase.GridVScrolled(Me, e)
End Sub

Public Sub SynHScroll(ByVal e As ScrollEventArgs)
MyBase.GridHScrolled(Me, e)
End Sub
End Class

-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=--=-=-=-
 
K

Ken Tucker [MVP]

Hi,

What do you mean by writeable column does not update when editing
it?

Ken
------------------------
I have a datagrid control that I've inherited from the base datagrid control
(Source below).

I am applying a datatable style onto the datatable that I assign as my
datasource.

All of my column but one are set as readonly=true. The writeable column
does not update when I'm editing it. Is there something
different that I need to be doing to update this data? Also, how do I get
the "new row" to not appear at the bottom of the
datagrid?

Thanks

Scott

-=-=-=-=-=-=-=-=- Source -=-=-=-=-=-=-=-=-

Public Class MyDataGrid
Inherits DataGrid

Public Event MyVScroll As ScrollEventHandler
Public Event MyHScroll As ScrollEventHandler

Protected Overrides Sub GridVScrolled(ByVal sender As Object, ByVal e As
ScrollEventArgs)
MyBase.GridVScrolled(Me, e)
OnMyVScroll(e)
End Sub

Protected Overrides Sub GridHScrolled(ByVal sender As Object, ByVal e As
ScrollEventArgs)
MyBase.GridHScrolled(sender, e)
OnMyHScroll(e)
End Sub

Protected Sub OnMyVScroll(ByVal e As ScrollEventArgs)
RaiseEvent MyVScroll(Me, e)
End Sub

Protected Sub OnMyHScroll(ByVal e As ScrollEventArgs)
RaiseEvent MyHScroll(Me, e)
End Sub

Public Sub SynVScroll(ByVal e As ScrollEventArgs)
MyBase.GridVScrolled(Me, e)
End Sub

Public Sub SynHScroll(ByVal e As ScrollEventArgs)
MyBase.GridHScrolled(Me, e)
End Sub
End Class

-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=--=-=-=-
 
S

Scott Meddows

The column that is not set to Readonly.

I will edit the value in the datagrid, click onto another cell and the value in the cell returns to the old value.
 
K

Ken Tucker [MVP]

Hi,

Could you please post the code showing how to define your tablestyle
and bind the grid.

Ken
 
S

Scott Meddows

My binding....

NewResolveDisplayDataGrid.DataSource = noAdjudicationYetDataSet.Tables(0).DefaultView
NewResolveEditDataGrid.DataSource = noAdjudicationYetDataSet.Tables(1).DefaultView

The Table Style
-=-=-=-=-=-=-
'
'NewEPRRunTableStyle
'
Me.NewEPRRunTableStyle.AllowSorting = False
Me.NewEPRRunTableStyle.DataGrid = Me.NewResolveEditDataGrid
Me.NewEPRRunTableStyle.GridColumnStyles.AddRange(New System.Windows.Forms.DataGridColumnStyle() {Me.NameColumn,
Me.PayerDescColumn, Me.SourceColumn, Me.InputColumn, Me.Reached90Column})
Me.NewEPRRunTableStyle.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.NewEPRRunTableStyle.MappingName = "Table1"
Me.NewEPRRunTableStyle.RowHeadersVisible = False
'
'NameColumn
'
Me.NameColumn.Format = ""
Me.NameColumn.FormatInfo = Nothing
Me.NameColumn.HeaderText = "Facility"
Me.NameColumn.MappingName = "name"
Me.NameColumn.ReadOnly = True
Me.NameColumn.Width = 200
'
'PayerDescColumn
'
Me.PayerDescColumn.Format = ""
Me.PayerDescColumn.FormatInfo = Nothing
Me.PayerDescColumn.HeaderText = "Payer Class"
Me.PayerDescColumn.MappingName = "PayerDesc"
Me.PayerDescColumn.NullText = ""
Me.PayerDescColumn.ReadOnly = True
Me.PayerDescColumn.Width = 130
'
'SourceColumn
'
Me.SourceColumn.Format = ""
Me.SourceColumn.FormatInfo = Nothing
Me.SourceColumn.HeaderText = "Billing Company"
Me.SourceColumn.MappingName = "Source"
Me.SourceColumn.ReadOnly = True
Me.SourceColumn.Width = 87
'
'InputColumn
'
Me.InputColumn.Format = ""
Me.InputColumn.FormatInfo = Nothing
Me.InputColumn.HeaderText = "$/PP"
Me.InputColumn.MappingName = "InputDPP"
Me.InputColumn.NullText = ""
Me.InputColumn.Width = 55
'
'Reached90Column
'
Me.Reached90Column.FalseValue = ""
Me.Reached90Column.HeaderText = "90% ?"
Me.Reached90Column.MappingName = "Marker"
Me.Reached90Column.NullText = ""
Me.Reached90Column.NullValue = CType(resources.GetObject("Reached90Column.NullValue"), Object)
Me.Reached90Column.ReadOnly = True
Me.Reached90Column.TrueValue = "X"
Me.Reached90Column.Width = 63
 
S

Scott Meddows

BTW - There are a few columns that come back from the database that are in that dataset that I don't display or include in the
tablestyle.
 
K

Ken Tucker [MVP]

Hi,

Scott I am really not seeing anything that would prevent the
datagrid from allowing you to edit the data. I do not see where you declare
InputColumn. I assume that is a datagridtextboxcolumn if not the problem
could be in the column style.


Ken
--------------------------
My binding....

NewResolveDisplayDataGrid.DataSource =
noAdjudicationYetDataSet.Tables(0).DefaultView
NewResolveEditDataGrid.DataSource =
noAdjudicationYetDataSet.Tables(1).DefaultView

The Table Style
-=-=-=-=-=-=-
'
'NewEPRRunTableStyle
'
Me.NewEPRRunTableStyle.AllowSorting = False
Me.NewEPRRunTableStyle.DataGrid = Me.NewResolveEditDataGrid
Me.NewEPRRunTableStyle.GridColumnStyles.AddRange(New
System.Windows.Forms.DataGridColumnStyle() {Me.NameColumn,
Me.PayerDescColumn, Me.SourceColumn, Me.InputColumn, Me.Reached90Column})
Me.NewEPRRunTableStyle.HeaderForeColor =
System.Drawing.SystemColors.ControlText
Me.NewEPRRunTableStyle.MappingName = "Table1"
Me.NewEPRRunTableStyle.RowHeadersVisible = False
'
'NameColumn
'
Me.NameColumn.Format = ""
Me.NameColumn.FormatInfo = Nothing
Me.NameColumn.HeaderText = "Facility"
Me.NameColumn.MappingName = "name"
Me.NameColumn.ReadOnly = True
Me.NameColumn.Width = 200
'
'PayerDescColumn
'
Me.PayerDescColumn.Format = ""
Me.PayerDescColumn.FormatInfo = Nothing
Me.PayerDescColumn.HeaderText = "Payer Class"
Me.PayerDescColumn.MappingName = "PayerDesc"
Me.PayerDescColumn.NullText = ""
Me.PayerDescColumn.ReadOnly = True
Me.PayerDescColumn.Width = 130
'
'SourceColumn
'
Me.SourceColumn.Format = ""
Me.SourceColumn.FormatInfo = Nothing
Me.SourceColumn.HeaderText = "Billing Company"
Me.SourceColumn.MappingName = "Source"
Me.SourceColumn.ReadOnly = True
Me.SourceColumn.Width = 87
'
'InputColumn
'
Me.InputColumn.Format = ""
Me.InputColumn.FormatInfo = Nothing
Me.InputColumn.HeaderText = "$/PP"
Me.InputColumn.MappingName = "InputDPP"
Me.InputColumn.NullText = ""
Me.InputColumn.Width = 55
'
'Reached90Column
'
Me.Reached90Column.FalseValue = ""
Me.Reached90Column.HeaderText = "90% ?"
Me.Reached90Column.MappingName = "Marker"
Me.Reached90Column.NullText = ""
Me.Reached90Column.NullValue =
CType(resources.GetObject("Reached90Column.NullValue"), Object)
Me.Reached90Column.ReadOnly = True
Me.Reached90Column.TrueValue = "X"
Me.Reached90Column.Width = 63
 
S

Scott Meddows

Yes, they are all textboxcolumns...


Ken Tucker said:
Hi,

Scott I am really not seeing anything that would prevent the
datagrid from allowing you to edit the data. I do not see where you declare
InputColumn. I assume that is a datagridtextboxcolumn if not the problem
could be in the column style.


Ken
--------------------------
My binding....

NewResolveDisplayDataGrid.DataSource =
noAdjudicationYetDataSet.Tables(0).DefaultView
NewResolveEditDataGrid.DataSource =
noAdjudicationYetDataSet.Tables(1).DefaultView

The Table Style
-=-=-=-=-=-=-
'
'NewEPRRunTableStyle
'
Me.NewEPRRunTableStyle.AllowSorting = False
Me.NewEPRRunTableStyle.DataGrid = Me.NewResolveEditDataGrid
Me.NewEPRRunTableStyle.GridColumnStyles.AddRange(New
System.Windows.Forms.DataGridColumnStyle() {Me.NameColumn,
Me.PayerDescColumn, Me.SourceColumn, Me.InputColumn, Me.Reached90Column})
Me.NewEPRRunTableStyle.HeaderForeColor =
System.Drawing.SystemColors.ControlText
Me.NewEPRRunTableStyle.MappingName = "Table1"
Me.NewEPRRunTableStyle.RowHeadersVisible = False
'
'NameColumn
'
Me.NameColumn.Format = ""
Me.NameColumn.FormatInfo = Nothing
Me.NameColumn.HeaderText = "Facility"
Me.NameColumn.MappingName = "name"
Me.NameColumn.ReadOnly = True
Me.NameColumn.Width = 200
'
'PayerDescColumn
'
Me.PayerDescColumn.Format = ""
Me.PayerDescColumn.FormatInfo = Nothing
Me.PayerDescColumn.HeaderText = "Payer Class"
Me.PayerDescColumn.MappingName = "PayerDesc"
Me.PayerDescColumn.NullText = ""
Me.PayerDescColumn.ReadOnly = True
Me.PayerDescColumn.Width = 130
'
'SourceColumn
'
Me.SourceColumn.Format = ""
Me.SourceColumn.FormatInfo = Nothing
Me.SourceColumn.HeaderText = "Billing Company"
Me.SourceColumn.MappingName = "Source"
Me.SourceColumn.ReadOnly = True
Me.SourceColumn.Width = 87
'
'InputColumn
'
Me.InputColumn.Format = ""
Me.InputColumn.FormatInfo = Nothing
Me.InputColumn.HeaderText = "$/PP"
Me.InputColumn.MappingName = "InputDPP"
Me.InputColumn.NullText = ""
Me.InputColumn.Width = 55
'
'Reached90Column
'
Me.Reached90Column.FalseValue = ""
Me.Reached90Column.HeaderText = "90% ?"
Me.Reached90Column.MappingName = "Marker"
Me.Reached90Column.NullText = ""
Me.Reached90Column.NullValue =
CType(resources.GetObject("Reached90Column.NullValue"), Object)
Me.Reached90Column.ReadOnly = True
Me.Reached90Column.TrueValue = "X"
Me.Reached90Column.Width = 63
 
S

Scott Meddows

Again, figured it out!

I had an Expression on the datacolumn of "0.00". I thought I could just use that for the default value when it is really an
expression that gets evaluated and displayed.

I'm so stupid.

Thanks for the help, guys!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top