|
-
Aug 22nd, 2003, 04:06 AM
#1
Thread Starter
Registered User
Problem with adding columns to DataGrid [Resolved]
Currently my DataGrid has 3 columns. These 3 columns are from a DataSet which refer to a database.
I want to add 1 extra column to DataGrid, so that user can check/tick on it to indicate a row is selected.
can i do so?
actually i read through the MSDN help file
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/vbcon/html/vbtskcreatingcustomcolumntypesindatagrid.htm
i follow exactly this MSDN help file but cannot get what I want.
please guide me thank you.
Last edited by albertlse; Aug 24th, 2003 at 09:53 PM.
-
Aug 22nd, 2003, 02:58 PM
#2
Sleep mode
To get selected row , do this :
VB Code:
MsgBox("Row number is " & DataGrid1.CurrentCell.RowNumber)
-
Aug 22nd, 2003, 03:01 PM
#3
Sleep mode
I've just realized , this is easier and clearer :
VB Code:
Private Sub DataGrid1_CurrentCellChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
'This method :
MsgBox("Row number is " & DataGrid1.CurrentCell.RowNumber)
'Or this method :
'MsgBox(DataGrid1.CurrentRowIndex())
End Sub
-
Aug 22nd, 2003, 08:40 PM
#4
Thread Starter
Registered User
I've just realized , this is easier and clearer :
visual basic code:--------------------------------------------------------------------------------
Private Sub DataGrid1_CurrentCellChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
'This method :
MsgBox("Row number is " & DataGrid1.CurrentCell.RowNumber)
'Or this method :
'MsgBox(DataGrid1.CurrentRowIndex())
End Sub
Pirate,
Actually what I want to do is like this:
I load all employees' data in the dataset.
The DataGrid is binded to the dataset. So it will display all employee's data.
I will like to make user select those desired rows.
Then the PrintDocument will print those selected rows.
According to your code, can it do, or can it be modify to suit what I want?
Please guide, or suggest. thank you.
-
Aug 23rd, 2003, 11:43 AM
#5
Sleep mode
That code only shows you which row was selected or click by the user . It's part of what you been asking I believe .
-
Aug 24th, 2003, 09:54 AM
#6
Thread Starter
Registered User
That code only shows you which row was selected or click by the user . It's part of what you been asking I believe .
Pirate, you are right. that's part of what i been asking.
So if I selected multiple rows (by holding Shift/Ctrl key and click on the rows that I wanted to be selected), what function can I call to retrieve all the selected rows' number?
Please guide, thank you.
-
Aug 24th, 2003, 12:03 PM
#7
Sleep mode
Try this :
VB Code:
Private Sub DataGrid1_CurrentCellChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
Dim i As Integer
For i = 0 To DataGrid1.VisibleRowCount - 1
If DataGrid1.IsSelected(i) = True Then
MsgBox(DataGrid1.Item(i, 0))
End If
Next
End Sub
-
Aug 24th, 2003, 09:52 PM
#8
Thread Starter
Registered User
thanx Pirate! this is exactly wat i wanted!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|