Hi, thanks for answering. I have to process the data from the database and place it in a datatable in order to do it. In brief I'm doing something like this:
1) Read the data from SQL and put it in a datatabel (dt_aux). 2) Process dt_aux and place it into dt with this line dt=filtra_activas(dt_aux.Copy()); 3) Assign the dt to the datagridview every time, since otherwise it doesn't notice wether the dt have changed. So I cannot bind directly the datagridview with the SQL. Any other idea? (or maybe go further on the explanation on this one if I've got it wrong) On Feb 20, 4:31 pm, Vinicius Quaiato <[email protected]> wrote: > Hi, > > Try to bind a SqlDataSource in the Grid, then just call the DataBind() > method instead of set the DataSource; > > 2009/2/20 Nacho108 <[email protected]> > > > > > Hi Everyone ! > > > I'm having a problem with a Datagridview control, I hope somebody can > > help me since I tried many things but I cannot nail the solution. > > I have a Datagridview displaying the contents of a database that > > change continuously, but the changes are minimum (around 2 or 3 rows > > change over 180, every 10 seconds), and I'm reading this database > > through a separated thread and then refreshing the datagridview each > > 10 seconds. All the threading thing is already debugged and working > > fine. The problem is not connected with it. > > The user should be able to scroll the datagridview normally during the > > refresh process, but it happens that when the program comes to this > > line where I update the datagridview itself (after reading the > > database): > > > dataGridView1.DataSource = dt; (dt is a datatable which I populate > > with database values) > > > If I were scrolling with the mouse, the mouse looses control and I > > have to take again the scroll bar, this is very anoying for the user > > since refresh is very often. > > > I don't know if I'm doing things right, so I have a few questions: > > > 1) If I don't assign the datasource in each database reading, the > > control doesn't refresh its content. Is this normal? The datagridview > > content shouldn't automatically follow the content of dt (datatable)? > > > 2) In case this assign I describe before is necessary, is there a way > > to avoiding this loose of control I'm experimenting? > > > Thanks in advance > > Nacho
