提交表单后,似乎字段值被设置为空.我正在做一些表单验证; 如果表单无效我正在显示错误列表中的错误消息,但我希望字段值保持不变.有没有办法做到这一点?
这是我验证表单的视图:
@app.route('/booking', methods=['GET', 'POST'])
def booking():
errors = []
if request.method == 'GET':
return render_template('booking.html', errors=errors)
else:
# grab values from form fields and store them in objects
start_date = request.form['start_date']
end_date = request.form['end_date']
name = request.form['name'].strip()
email = request.form['email'].strip()
# check if all fields are non-empty and raise an error if not
if not start_date or not end_date or not name or not email:
errors.append('Please enter all the fields.')
else:
# converts dates to Unix time-stamp for …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个事件,当我在datgridview中右键单击一行时显示上下文菜单.
以下是正在发生的问题的图像:

这是我目前使用的代码:
Private Sub dgvStudents_CellMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles dgvStudents.CellMouseDown
Dim rowClicked As DataGridView.HitTestInfo = dgvStudents.HitTest(e.X, e.Y)
'Select Right Clicked Row if its not the header row
If e.Button = Windows.Forms.MouseButtons.Right AndAlso e.RowIndex > -1 Then
'Clear any currently sellected rows
dgvStudents.ClearSelection()
Me.dgvStudents.Rows(e.RowIndex).Selected = True
ContextMenuStrip1.Show(dgvStudents, Control.MousePosition)
End If
End Sub
Run Code Online (Sandbox Code Playgroud)
PS屏幕截图不会显示我的光标>.>但它肯定不会与上下文菜单同步!
编辑:好的伙计我已经解决了,
我只是将Control.MousePosition替换为MousePosition,它就可以了!