How can i trigger Leave Cell event for Msflexgrid through command button click or textbox lost focus.

If you say LeaveCell, does this mean that another control must get the focus, or just move on to the next cell?

when i click on another control outside msflexgrid.

I am using textbox, combobox to enter data on msflexgrid. when i type in textbox and click on another control outside msflexgrid levecell dosen trigger.

The reason is because when you click on say a command button to add the data to the grid, the last thing that happens is the grid accepting the data. Thats why the focus is on the grid cell. Try to use something like -

Text1.SetFocus

AFTER you made the update call to the grid.:)

Private Sub MFGCDEDIT_EnterCell()
If MFGCDEDIT.MouseRow = 0 Then

Text1.Visible = False  '

Exit Sub
End If

If MFGCDEDIT.Col = 4 Then

'cleare content of current cell
Text1.Text = ""
'place textbox over current cell
Text1.Visible = False
Text1.Top = MFGCDEDIT.Top + MFGCDEDIT.CellTop
Text1.Left = MFGCDEDIT.Left + MFGCDEDIT.CellLeft
Text1.Width = MFGCDEDIT.CellWidth
'ASSiGN CELL CONTENT TO TEXTBOX
Text1.Text = MFGCDEDIT.Text
Text1.Visible = True
Text1.SetFocus
End If
End Sub

Private Sub MFGCDEDIT_LeaveCell()
If MFGCDEDIT.Col = 2 Then
MFGCDEDIT.Text = Format(Text1.Text, "#,##0.00")
Text1.Visible = False
End If
End Sub

when i click on coloum 4 , Text1 getfocus . if thereafter i click outside ms flexgrid msflexgrid leave cell event dosen trigger and text1 remains visible. i want leave cell event to trigger.

Private Sub MFGCDEDIT_LeaveCell()
If MFGCDEDIT.Col = 2 Then
MFGCDEDIT.Text = Format(Text1.Text, "#,##0.00")
Text1.Visible = False
End If
If MFGCDEDIT.Col = 2 Then

Should this not be .Col = 3 if you are selecting column 4? That's maybe why your event is not triggered, you are in the wrong column.:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.