Hi,
I've done something similar in a current project but instead of using a
DataGrid I used a ListView.
Check out MSDN and search for this example as a basic start:
"Add Method (ListItems, ColumnHeaders), SubItems Property Example"
Next:
Private Sub ListView1.ItemClick(ByVal Item as MSComctlLib.ListItem)
'Put your code in here to detect the right mouse click
End Sub
I had a zero width column that held the primary key so it could be used to
reference the table.
The menu item then referenced the 'Item' from ItemClick.
First two columns were 'StartDate' and 'FinishDate', the third was the zero
length column with 'RecordID'
myValue = Item.SubItems(2) 'Read as a String
Then myValue was used to interact with the database and delete the relevant
record.
I know it's not what you were after but it's an alternative, especially if
you are after read-only data from the users point of view.
Carl
----- Original Message -----
From: <RPAmog@s...>
To: "professional vb" <pro_vb@p...>
Sent: Monday, February 26, 2001 5:29 AM
Subject: [pro_vb] 2 questions about datagrid
> 1. I have a form with a datagrid. I alsa created a menu that's whose
> visible property is set to false. When a row is right-clicked using the
> mouse, the menu is popped-up and the user is asked if he wants to delete
the
> row. The problem is, how do I delete this particular row via code? By
the
> way, the grid is populated by an adodb recordset and is locked.
>
> 2. One way to avoid the above scenario is to not lock the datagrid and
have
> the AllowDelete property checked. The user can then delete any row he
wants
> just by pressing the delete button. But at the same time, I don't want
the
> user to be able to edit the contents of the datagrid. So if I go with
this
> alternative, how then do I prevent a user from modifying the cells in the
> datagrid? Is there a way to disable only some columns in a datagrid?
>
> Thanks.
>
> Ramon