Thanks everybody for the many replies. I am including the code I use to
create my very simple datagrid. I am only concerned about the first column,
when the user changes it.
'------DataGrid1 TABLESTYLE----------------------
Dim ts As DataGridTableSt yle
DataGrid1.DataS ource = DS1
DataGrid1.DataM ember = "rooms"
ts = New DataGridTableSt yle
ts.MappingName = "rooms"
ts.PreferredRow Height = 25
ts.AlternatingB ackColor = System.Drawing. Color.Gainsboro
ts.HeaderBackCo lor = System.Drawing. Color.Gainsboro
ts.HeaderForeCo lor = System.Drawing. Color.Black
'-------dg_punch COLUMNSTYLES----------------------
Dim tb1 As DataGridTextBox Column
tb1 = New DataGridTextBox Column
tb1.HeaderText = "Room Number"
tb1.MappingName = "roomno"
tb1.NullText = ""
tb1.Width = 150
ts.GridColumnSt yles.Add(tb1)
Dim tb2 As DataGridTextBox Column
tb2 = New DataGridTextBox Column
tb2.HeaderText = "Room Description"
tb2.MappingName = "roomdesc"
tb2.NullText = ""
tb2.Width = 350
ts.GridColumnSt yles.Add(tb2)
DataGrid1.Table Styles.Add(ts)
So, what would my code look like to do the validating? I am fairly new to
VB.NET and have not created a 'handler' yet. I would appreciate any
information.
Thanks again,
Steve
"jim" <james_matthews _at_shi_dotcom> wrote in message
news:ed******** ******@TK2MSFTN GP09.phx.gbl...
Hi Steve,
if you create a table style and a subsequent columnstyle for each column
to be displayed in your grid then you can handle the
"myDataGridColu mnStyle.TextBox .Validating" event. I believe you could also
handle the myDataGridColum nStyle.TextBox. LostFocus event, but the
validating event may be more appropriate for what you're specifically doing.
I'm handling this in one of my applications and it works nicely. You'll
have to manually add the handler to the control using the AddHandler statement.
i.e.
in form load or wherever it makes sense for you...
\\\
AddHandler myDataGridColum nStyle.TextBox. Validating, AddressOf
myValidatingHan dler
///
if you need further details don't hesitate to ask.
jim
"Steve" <sf*****@flinti nd-remove.com> wrote in message
news:eM******** ******@tk2msftn gp13.phx.gbl... I have a datagrid in a WinForm.
When the user edits an entry in the datagrid, after he leaves that
field, I would like to do some cheking. What event fires when the user does that?
I need to make sure that the value he modified does not create a dup
value in my DB.
Thank you for your help,
Steve