怎么做验证? [英] How to do validation?

查看:95
本文介绍了怎么做验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在做一个基于窗口的项目.
在我的datagridview中,我有五个字段.
1.文件量2.DateOfOpening 3.DateOfClosing 4.DateOfDestroy和5.Status是组合框.
在此组合框中,我有三个项目,即活动",已关闭"和已销毁".
当用户从组合框中选择活动"时,仅应弹出DateOfOpening的日期时间选择器,而不应弹出其他日期时间选择器.
当用户从组合框中选择销毁"时,仅应弹出DateOfClosing的日期时间选择器,反之亦然.
我正在打开日期时间选择器,但不能满足这些条件.这是我在下面的代码:


i am doing a project which is window based.
in my datagridview i have five fields.
1.Volume of File 2.DateOfOpening 3.DateOfClosing 4.DateOfDestroy and 5.Status which is a combobox.
Within this combobox i have three items i.e Active,Closed and Destroyed.
when the user selects Active from the combobox,only the datetime picker of DateOfOpening should pop up and others should not pop up.
when user selects Destroy from the combobox,only datetime picker of DateOfClosing should pop Up and vice versa.
i have am opening the datetime picker but cant do with these conditions.this is my coding below:

int _colIndex = e.ColumnIndex;
string _colName = null;
_colName = dgFileDetails.Columns[_colIndex].Name;
 CommonControls.IPicker objPicker = null;
 if (BlCommon.ValidateColumnFordate(_colName))
 {
 objPicker = new CommonControls.DatePicker();
 if (objPicker != null)
 {
 if (_colIndex == dgFileDetails.Columns[_colName].Index)
 {
 objPicker.ShowDialog();
 if (objPicker.Tag != null)
 {
 dgFileDetails[_colName, e.RowIndex].Value = objPicker.Tag;
 dgFileDetails[_colName, e.RowIndex].ReadOnly = true;
 }
 }
 }
}

public static bool ValidateColumnFordate(string columnName)
{
string temp = columnName.Substring(0, 4);
if (temp.ToLower() == "date")
return true;
else
return false;
}

推荐答案

实际上我刚刚醒来,却有点困惑!!
但总的来说,您可能会充分利用已启用"属性
您可以通过将其设置为false来禁用或启用任何控件.
这是最简单的方法.
actually i just waked up and im littile confused!!
but in general you may have a good use of "enabled" property
you can disable or enable any control by setting it to false.
this is most easier way.


这篇关于怎么做验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆