Fill datatable

R

ruca

hi,

How can I fill some DataTable by clicking in cells of a DataGrid control?

NOTE: I don't want to select a entire row, ok? I must select only one or
more cells...

I have a DataGrid that have some data that I must select what I want and
then by clicking in a Button it will create some records in DataBase.
So I want to construct a DataTable by clicking in DataGrid, for then allows
me to cover this DataTable and create the records in DB.
 
C

Chris

ruca said:
hi,

How can I fill some DataTable by clicking in cells of a DataGrid control?

NOTE: I don't want to select a entire row, ok? I must select only one or
more cells...

I have a DataGrid that have some data that I must select what I want and
then by clicking in a Button it will create some records in DataBase.
So I want to construct a DataTable by clicking in DataGrid, for then allows
me to cover this DataTable and create the records in DB.


The example below is used to make it so no column can be selected but
selects the entire row instead. Add it to your datagridtablestyle.
Then you will need to capture the click event in the datagrid (probably
should just be capture the row change instead) and do a datagridhittest
on it.

Hope that helps
Chris

FullDisclosure: This was used from some website... No idea who
Public Class DataGridNoActiveCellColumn
Inherits DataGridTextBoxColumn

Private SelectedRow As Integer = -1
Protected Overloads Overrides Sub Edit(ByVal source As
System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal
bounds As System.Drawing.Rectangle, ByVal [readOnly] As Boolean, ByVal
instantText As String, ByVal cellIsVisible As Boolean)

'make sure previous selection is valid
If SelectedRow > -1 And SelectedRow < source.List.Count + 1 Then
Me.DataGridTableStyle.DataGrid.UnSelect(SelectedRow)
End If
SelectedRow = rowNum
Me.DataGridTableStyle.DataGrid.Select(SelectedRow)
End Sub

End Class
 
R

ruca

hi,

I think that you're talking about Windows Forms, and I'm talk about Web
Forms. It's a quiet different...

Thank's anyway


--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

Chris said:
ruca said:
hi,

How can I fill some DataTable by clicking in cells of a DataGrid control?

NOTE: I don't want to select a entire row, ok? I must select only one or
more cells...

I have a DataGrid that have some data that I must select what I want and
then by clicking in a Button it will create some records in DataBase.
So I want to construct a DataTable by clicking in DataGrid, for then
allows me to cover this DataTable and create the records in DB.


The example below is used to make it so no column can be selected but
selects the entire row instead. Add it to your datagridtablestyle. Then
you will need to capture the click event in the datagrid (probably should
just be capture the row change instead) and do a datagridhittest on it.

Hope that helps
Chris

FullDisclosure: This was used from some website... No idea who
Public Class DataGridNoActiveCellColumn
Inherits DataGridTextBoxColumn

Private SelectedRow As Integer = -1
Protected Overloads Overrides Sub Edit(ByVal source As
System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal
bounds As System.Drawing.Rectangle, ByVal [readOnly] As Boolean, ByVal
instantText As String, ByVal cellIsVisible As Boolean)

'make sure previous selection is valid
If SelectedRow > -1 And SelectedRow < source.List.Count + 1 Then
Me.DataGridTableStyle.DataGrid.UnSelect(SelectedRow)
End If
SelectedRow = rowNum
Me.DataGridTableStyle.DataGrid.Select(SelectedRow)
End Sub

End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top