PC Review


Reply
Thread Tools Rate Thread

Add Row Manually to DataGrid

 
 
DraguVaso
Guest
Posts: n/a
 
      22nd Jul 2004
Hi,

I have a DataGrid to which I want the program add from time to time a new
row, without redrawing the whole DataGrid. So I don't want to add the new
Row to the DataSource and than do a Refresh, but I want it kind of directly
add it to the DataGrid so it only adds the new row.

Does anybody knows how to do this? Or what I'd better use for this?

The reason I want it is that repainting the (Custom)DataGrid takes some
time, and I don't want to repaint it the whole time when I Add a new Row
(every 5-6 seconds a new Row should be added).

Thanks a lot in advance,

Pieter


 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      22nd Jul 2004
Hi Pieter,

I try to get it clear to me, do you mean you want to set the datasource to
nothing and after that set it again, is that something you want to archieve?

:-)

Cor


 
Reply With Quote
 
DraguVaso
Guest
Posts: n/a
 
      22nd Jul 2004
Well I don't knwo really :-)
I just have a DataGrid with like 20 rows in it. I have a process that is
turning, and that should add every 5 seconds a new Row to my DataGrid.

When the new Row is added, I don't want that it repaints the whole DataGrid,
but just adds the new row at the end of it.. :-)

"Cor Ligthert" <(E-Mail Removed)> wrote in message
news:%23kTzDt%(E-Mail Removed)...
> Hi Pieter,
>
> I try to get it clear to me, do you mean you want to set the datasource to
> nothing and after that set it again, is that something you want to

archieve?
>
> :-)
>
> Cor
>
>



 
Reply With Quote
 
Ken Tucker [MVP]
Guest
Posts: n/a
 
      22nd Jul 2004
Hi,

The datagrid will redraw itself when you add a row. Post your code
for the datagrid column style maybe we can help speed it up some.

Ken
-----------------------
"DraguVaso" <(E-Mail Removed)> wrote in message
news:ufIXzn%(E-Mail Removed)...
Hi,

I have a DataGrid to which I want the program add from time to time a new
row, without redrawing the whole DataGrid. So I don't want to add the new
Row to the DataSource and than do a Refresh, but I want it kind of directly
add it to the DataGrid so it only adds the new row.

Does anybody knows how to do this? Or what I'd better use for this?

The reason I want it is that repainting the (Custom)DataGrid takes some
time, and I don't want to repaint it the whole time when I Add a new Row
(every 5-6 seconds a new Row should be added).

Thanks a lot in advance,

Pieter



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      22nd Jul 2004
Hi Pieter,

I was curious and made this, in my idea this goes in batches, what is it you
want to archieve what you said, however it goins very smooth on this sunny
day here.

:-)

Cor

Dim dt As DataTable
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
dt = New DataTable("Pieter")
dt.Columns.Add("Time", GetType(System.DateTime))
DataGrid1.DataSource = dt
Dim ts As New DataGridTableStyle
ts.MappingName = "Pieter"
Dim column As New DataGridTextBoxColumn
ts.GridColumnStyles.Add(column)
DataGrid1.TableStyles.Add(ts)
column.MappingName = "Time"
column.HeaderText = "Tijd"
column.Width = 50
column.Format = ("HH:mm:ss")
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Timer1.Tick
For i As Integer = 0 To 20
Dim dr As DataRow = dt.NewRow
dr(0) = Now
dt.Rows.Add(dr)
DataGrid1.ScrollToRow(dt.Rows.Count - 1)
Next
End Sub
End Class
Public Class MyDataGrid
Inherits DataGrid
Sub ScrollToRow(ByVal row As Integer)
If Not Me.DataSource Is Nothing Then
Me.GridVScrolled(Me, _
New ScrollEventArgs(ScrollEventType.LargeIncrement, row))
End If
End Sub
End Class




 
Reply With Quote
 
DraguVaso
Guest
Posts: n/a
 
      22nd Jul 2004
Thanks Cor!
I tried it and indeed it goes very smooth, hehe :-)
Once again I was looking to far and made it too complicated, hehe :-)

Thanks a lot! And enjoy the sun overthere! Here below it's sunny too :-)

Pieter

"Cor Ligthert" <(E-Mail Removed)> wrote in message
news:%23ukGqW$(E-Mail Removed)...
> Hi Pieter,
>
> I was curious and made this, in my idea this goes in batches, what is it

you
> want to archieve what you said, however it goins very smooth on this sunny
> day here.
>
> :-)
>
> Cor
>
> Dim dt As DataTable
> Private Sub Form1_Load(ByVal sender As Object, _
> ByVal e As System.EventArgs) Handles MyBase.Load
> dt = New DataTable("Pieter")
> dt.Columns.Add("Time", GetType(System.DateTime))
> DataGrid1.DataSource = dt
> Dim ts As New DataGridTableStyle
> ts.MappingName = "Pieter"
> Dim column As New DataGridTextBoxColumn
> ts.GridColumnStyles.Add(column)
> DataGrid1.TableStyles.Add(ts)
> column.MappingName = "Time"
> column.HeaderText = "Tijd"
> column.Width = 50
> column.Format = ("HH:mm:ss")
> End Sub
> Private Sub Timer1_Tick(ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles Timer1.Tick
> For i As Integer = 0 To 20
> Dim dr As DataRow = dt.NewRow
> dr(0) = Now
> dt.Rows.Add(dr)
> DataGrid1.ScrollToRow(dt.Rows.Count - 1)
> Next
> End Sub
> End Class
> Public Class MyDataGrid
> Inherits DataGrid
> Sub ScrollToRow(ByVal row As Integer)
> If Not Me.DataSource Is Nothing Then
> Me.GridVScrolled(Me, _
> New ScrollEventArgs(ScrollEventType.LargeIncrement, row))
> End If
> End Sub
> End Class
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Manually Add Row to Datagrid Jason Microsoft Dot NET 1 30th Sep 2005 10:23 AM
RE: DataGrid: how to make DataGrid sort manually? =?Utf-8?B?VFQgKFRvbSBUZW1wZWxhZXJlKQ==?= Microsoft C# .NET 0 15th Apr 2005 04:15 PM
Add Row Manually to DataGrid DraguVaso Microsoft Dot NET Framework Forms 5 22nd Jul 2004 03:38 PM
Add Row Manually to DataGrid DraguVaso Microsoft VB .NET 5 22nd Jul 2004 03:38 PM
Add Row Manually to DataGrid DraguVaso Microsoft ADO .NET 5 22nd Jul 2004 03:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:36 AM.