Adding two a Datagrid

  • Thread starter Thread starter Gerry Viator
  • Start date Start date
G

Gerry Viator

Hi all,

Ok I have a sub that creates a Datatable
loads some values then I bind it to a DataGrid to show
the user.

I later need to add values to the third Column in that datagrid?

Ok I tried a Global datatable but at the line where
Datagrid.Datadource = Datatable

it takes like 3 - 5 seconds?

thanks for any help
Gerry
 
Let me make sure I follow you. You have a datatable that can be seen
throughout the project. You fill it and all is well. But when you set the
datasource, it takes a while? How big is the table? How are you timing it?
If you are using the debugger or messageboxes, you may get a distorted
result.

Finally, how many columns are there? I'm not understanding adding values to
the third column. Is the column already there or do you need to add the
column? If it's there, is it calcuated (expression column) --- mainly, how
does it fit into the picture?
 
Thanks for Bill's quick response!

Hi Gerry,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when you bind a datagrid to a
DataTable, the binding process is very slow which takes about 3-5 seconds.
If there is any misunderstanding, please feel free to let me know.

Generally, this is common in debug mode if your table is very large.
Because when in debug mode, VS.NET IDE will have to attach debugger to the
application process, and sometimes we have to watch on variables. The IDE
also has to do stack trace and check breakpoints. So the binding process
might be very slow.

Would you please try to run it from windows explorer or press Ctrl + F5 in
IDE to see if it is still running very slow?

HTH. If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hello, and thanks for your help.

I noticed when the property "ReadOnly" is set to true on the datagrid it is
slow, when
set to false it is fast? Whether it's in Release or debug mode the same.
No messagebox to time it. It's just apparently about 3-5 second delay\pause.

Well, if like I said, in my post if I use a Public Datatable, the
Column(Value) will already be there when
it's time to load values.

If I just create in the Sub, then dispose it after the Datagrid is loaded
then
The datatable no longer is there.
T

EntryGrid.DataSource = ShownDataTable
ShownDataTable.Clear()

Dim HowManyColumnsPartOf As Integer = sHowManyColumnsPartOf
Dim ColumnLocation As Integer = sColumnLocation
Dim RowsCount As Integer = ShownDataTable.Rows.Count

Dim cols As DataColumnCollection
Dim iCol As Integer
cols = MainSavedDataTable.Columns
If cols.Contains(sEntryName) Then
iCol = (cols.IndexOf(sEntryName))
End If

If ShownDataTable.Columns.Count = 0 Then
Dim CntColumn As New DataColumn("Entry #")
CntColumn.DataType = GetType(Integer)
CntColumn.AutoIncrement = True
CntColumn.AutoIncrementSeed = 1
ShownDataTable.Columns.Add(CntColumn)

Dim CntColumn2 As New DataColumn("Entry Name")
CntColumn2.DataType = GetType(String)
ShownDataTable.Columns.Add(CntColumn2)

Dim CntColumn3 As New DataColumn("Value")
CntColumn3.DataType = GetType(String)
ShownDataTable.Columns.Add(CntColumn3)
Else

ShownDataTable.Columns(0).AutoIncrementSeed = 1

End If

thanks
Gerry
 
Hi Gerry,

I was trying to reproduce it with the code you have provided. But I was not
able to repro it. I think this performance issue might be caused by many
reasons. Do you have much data in the DataTable? How is your computer's
performance? Please provide us with more information, so we can deliver our
assistance more quickly.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Gerry,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi and thanks again for your help,

If I run the program by clicking Ctrl + F5 , it runs fast and no problems.
If I press debug in VS.NET and run that way it is slow at that point in the
program.
I just moved on since it works when it runs normally. I would still like to
know
why?

thanks
Gerry
 
Hi Gerry,

Like I mentioned in my former post, when you press F5 to run the
application in debug mode, VS.NET IDE will have to attach debugger to the
application process, and sometimes we have to watch on variables. The IDE
also has to do stack trace and check breakpoints. It really takes much
resource on doing these jobs. so the binding process might be very slow.

However, when press Ctrl + F5, the program is run in release mode and
nothing is affecting the execution of your program. So it is fast.

Hence, don't worry about this since it is running fast in release mode.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Gerry,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top