From: DIOS on
VB2005: I have a DataGridView that I fill with data through a SQL
query. That works great. After the query is done I add two columns and
then manually fill in the cells with a calculated value. When I do
this I cant see the values in the cells. They are not visible to the
user.The columns are there just the cell values do not show up.
However if I export the grid to a text file the cell values do get
exported. They just aren't visible to the user. Anyone have any hints
as to why that would be?

AGP
From: Onur Güzel on
On Jun 14, 5:30 am, DIOS <sindi...(a)gmail.com> wrote:
> VB2005: I have a DataGridView that I fill with data through a SQL
> query. That works great. After the query is done I add two columns and
> then manually fill in the cells with a calculated value. When I do
> this I cant see the values in the cells. They are not visible to the
> user.The columns are there just the cell values do not show up.
> However if I export the grid to a text file the cell values do get
> exported. They just aren't visible to the user. Anyone have any hints
> as to why that would be?
>
> AGP

It may be clearer if you send the code which is only the part that
you're adding values to the cells. Maybe a it is a resizing/cell
alignment problem about the columns or other.

Onur Guzel
From: DIOS on
On Jun 14, 2:53 am, Onur Güzel <kimiraikkone...(a)gmail.com> wrote:
> On Jun 14, 5:30 am, DIOS <sindi...(a)gmail.com> wrote:
>
> > VB2005: I have a DataGridView that I fill with data through a SQL
> > query. That works great. After the query is done I add two columns and
> > then manually fill in the cells with a calculated value. When I do
> > this I cant see the values in the cells. They are not visible to the
> > user.The columns are there just the cell values do not show up.
> > However if I export the grid to a text file the cell values do get
> > exported. They just aren't visible to the user. Anyone have any hints
> > as to why that would be?
>
> > AGP
>
> It may be clearer if you send the code which is only the part that
> you're adding values to the cells. Maybe a it is a resizing/cell
> alignment problem about the columns or other.
>
> Onur Guzel

My process goes through this:

dgv.DataSource = dt
dgv.ReadOnly = True

dgv.ReadOnly = False

'add column
dgv.Columns.Add("PntNum", "PntNum")
dgv.Columns("PntNum").ValueType = GetType(System.Int32)

For Each dgRow As DataGridViewRow In dgv.Rows
dgRow.Cells("PntNum").Value = dgRow.Index
Next dgRow


'move the point number column to first position
dgv.Columns("PntNum").DisplayIndex = 0

'refresh the grid
dgv.Refresh()

dgv.ReadOnly = True


AGP
From: Rich P on
Something you could try would be to create a persisted dataTable in a
persisted dataset (.xsd file from the Add Items template file - add a
dataset to your project). Create a table in this dataset (right click
inside the dataset window -- the .xsd window) and add a table. Add all
the columns you will need - including the 2 columns you add after the
query. Also -- add an Identity column to this table so that you can
easily find records to edit. Now, using a sqlDataAdapter, fill the
table using your query. This will only fill the columns that you specify
in the query, then fill the other 2 columns from within the application
using whatever your logic is.

Dim da As New SqlDataAdapter
Dim ds As New Dataset1

da.SelectCommand = New SqlCommand
da.SelectCommand.Connection = yourConnObj

da.SelectCommand.CommandText = "Select f1, f2, f3 From tblx"
da.Fill(ds.YourTbl)
'--now fill in the rest of your columns - you could loop through your
table using a dataRow object or you could use Linq To DataTable to
perform the equivalent of an Update Query on your local DataTable

'--then

Datagridview1.DataSource = ds.YourTbl '--everything should show up now.

'--I'm not sure if VS2005 supports linQ. May have to scratch that idea
and just go with the Loop thing.



Rich

*** Sent via Developersdex http://www.developersdex.com ***
From: DIOS on
On Jun 15, 11:31 am, Rich P <rpng...(a)aol.com> wrote:
> Something you could try would be to create a persisted dataTable in a
> persisted dataset (.xsd file from the Add Items template file - add a
> dataset to your project).  Create a table in this dataset (right click
> inside the dataset window -- the .xsd window) and add a table.  Add all
> the columns you will need - including the 2 columns you add after the
> query.  Also -- add an Identity column to this table so that you can
> easily find records to edit.  Now, using a sqlDataAdapter, fill the
> table using your query. This will only fill the columns that you specify
> in the query, then fill the other 2 columns from within the application
> using whatever your logic is.
>
> Dim da As New SqlDataAdapter
> Dim ds As New Dataset1
>
> da.SelectCommand = New SqlCommand
> da.SelectCommand.Connection = yourConnObj
>
> da.SelectCommand.CommandText = "Select f1, f2, f3 From tblx"
> da.Fill(ds.YourTbl)
> '--now fill in the rest of your columns - you could loop through your
> table using a dataRow object or you could use Linq To DataTable to
> perform the equivalent of an Update Query on your local DataTable
>
> '--then
>
> Datagridview1.DataSource = ds.YourTbl  '--everything should show up now.
>
> '--I'm not sure if VS2005 supports linQ.  May have to scratch that idea
> and just go with the Loop thing.  
>
> Rich
>
> *** Sent via Developersdexhttp://www.developersdex.com***

Thanks for the tip. The data comes from different siources and its
complex so at this point I dont want to change my queries. Im more
interested in why the two columns I added do not display the data in
the cells but on export they are there.

AGP