Updating a cell value

Jun 19, 2009 at 1:42 PM

From a button on a first display, I open a second display with a real sourcegrid, with values coming from communication with an external system on my PC COM1 port. I have a procedure called every 5 seconds, which sets the cell values and then call a refresh. I code in VB.NET , visual studio 2008. The grid with its static parts (row and colum headers) is defined in the second display form code. Here is my simplified code in the main form:

sub update_grid()
dim i,j as int16
for i=0 to 27
for j=0 to 31
if gridforms.grid1(i,j) is Nothing then
gridforms.grid(i,j)=new SourceGrid.Cells.Cell(tab_values(i,j).value)
else
gridforms.grid(i,j)=tab_values(i,j).value
end if
next
next
gridforms.grid.Refresh()
end sub

The problem. If a value coming from the COM port is updated in my tab_values, the value is not updated on my grid display. If I close and reopen the grid display, the new value is correctly displayed. What am I doing wrong? Also, if I add a button on the grid display, which calls the grid refresh, values are updated.

Sorry for maybe a basic question, but I am quite new to using sourcegrid and YES, trust me or not, I try to find the answer in the documentation and on the forum.

 

 

Jun 19, 2009 at 2:17 PM
when you talk about "first display" are you talking about forms? if you are sending data from one form to an other, you probably should post a message, (delegate) and then on receiving that message, update your grid and call refresh. I am guessing you are just having threading issues.
 
Also makes your your com port reading class is not being ran on the main message loop. it should be in its own independant thread.
 
Hope that helps,.
~D

On Fri, Jun 19, 2009 at 9:42 AM, syberia <notifications@codeplex.com> wrote:

From: syberia

From a button on a first display, I open a second display with a real sourcegrid, with values coming from communication with an external system on my PC COM1 port. I have a procedure called every 5 seconds, which sets the cell values and then call a refresh. I code in VB.NET , visual studio 2008. The grid with its static parts (row and colum headers) is defined in the second display form code. Here is my simplified code in the main form:

sub update_grid()
dim i,j as int16
for i=0 to 27
for j=0 to 31
if gridforms.grid1(i,j) is Nothing then
gridforms.grid(i,j)=new SourceGrid.Cells.Cell(tab_values(i,j).value)
else
gridforms.grid(i,j)=tab_values(i,j).value
end if
next
next
gridforms.grid.Refresh()
end sub

The problem. If a value coming from the COM port is updated in my tab_values, the value is not updated on my grid display. If I close and reopen the grid display, the new value is correctly displayed. What am I doing wrong? Also, if I add a button on the grid display, which calls the grid refresh, values are updated.

Sorry for maybe a basic question, but I am quite new to using sourcegrid and YES, trust me or not, I try to find the answer in the documentation and on the forum.

 

 

Read the full discussion online.

To add a post to this discussion, reply to this email (sourcegrid@discussions.codeplex.com)

To start a new discussion for this project, email sourcegrid@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jun 22, 2009 at 6:01 PM

My first display is a windows forms. And yes, I use one backgroundworker for my COM port reading, and another one for my COM port writing. I transform my code to use a delegate and it is the same problem. finally I find my bug. In my first post, I simplify my code, but the real code was (the idea is that I want to avoid an update of a cell being edited):

if gridforms.grid(i,j).grid.Focused=false then gridforms.grid(i,j).value=tab_values(i,j).value

My problem is that gridforms.grid(i,j).grid.Focused is not only true for the cell I am curently modifying the value, but for quite all the cells. So, due to this test, the new value coming from the COM port is never updated on the grid. I take off the test, and the grid is now refreshed at the refresh period I am choosen. Thanks for your advice.