小编Nic*_*kz2的帖子

35
推荐指数
3
解决办法
4万
查看次数

c#listview取消选择项目

我正在开发一个Windows应用程序,它有一个包含大量项目的ListView.当用户点击某个项目时,该应用会显示该项目的详细信息.然后,用户有机会编辑这些细节.用户应在每次更改后单击"保存"按钮,但当然并非总是如此.

如果用户进行了更改但未单击"保存",则应用程序会显示一个消息框,询问他们是否要保存更改.此框包含一个取消按钮,如果他们单击取消,我想短路选择其他项目并让用户保持他们正在编辑的那个.

我找不到这样做的方法,如果项目更改而不保存,我会从itemselecedchanged事件显示对话框,如果用户单击取消,我从事件中删除我的功能并手动更改所选项目,之后我返回事件的功能,但在此之后,事件调用和我手动选择的项目未被选中.

    private bool EnsureSelected()
    {
        bool continue_ = true;
        if (_objectChange)
        {
            var res = MessageBox.Show("Do you want to save changes?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
            switch (res)
            {
                case DialogResult.Cancel:
                    if (!string.IsNullOrEmpty(_selectedKey))
                    {
                        listView_Keys.ItemSelectionChanged -= listView_Keys_ItemSelectionChanged;
                        listView_Keys.Focus();
                        listView_Keys.Items[_selectedKey].Selected = true;
                        listView_Keys.ItemSelectionChanged += listView_Keys_ItemSelectionChanged;
                    }
                    continue_ = false;
                    break;
                case DialogResult.Yes:
                    button_Save.PerformClick();
                    _objectChange = false;
                    break;
                case DialogResult.No:
                    _objectChange = false;
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }              
        }
        return continue_;
    }
Run Code Online (Sandbox Code Playgroud)

更新::

我试过这个解决方案:

        public partial class Form1 : Form
{ …
Run Code Online (Sandbox Code Playgroud)

c# listview winforms

7
推荐指数
1
解决办法
2381
查看次数

如何让文本框只接受有效的电子邮件?

我希望我的文本框检查输入到文本框中的电子邮件是否有效。

到目前为止,我有:

if (!this.txtEmail.Text.Contains('@') || !this.txtEmail.Text.Contains('.')) 
{ 
    MessageBox.Show("Please Enter A Valid Email", "Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Error); 
}
Run Code Online (Sandbox Code Playgroud)

但这仅测试它是否具有“@”和“.”。在里面。

有没有办法让它检查它是否有 .com 等,并且只有一个“@”?

c# email textbox winforms visual-studio-2013

4
推荐指数
1
解决办法
3万
查看次数

如何擦除画布上绘制的线条?

我正在使用一个Canvas类在画布上绘制线条.现在我想用与使用橡皮擦的笔记本中类似的方式擦除画布中绘制的线条.我通过几个例子,但没有什么对我有用.

如果有人知道这个问题的解决方案,请你帮我解决这个问题.

Java代码

public class DrawView extends View implements OnTouchListener 
{
        private Canvas      m_Canvas;

        private Path        m_Path;

        private Paint       m_Paint;

        ArrayList<Pair<Path, Paint>> paths = new ArrayList<Pair<Path, Paint>>();

        ArrayList<Pair<Path, Paint>> undonePaths = new ArrayList<Pair<Path, Paint>>(); 

        private float mX, mY;

        private static final float TOUCH_TOLERANCE = 4;

        private Bitmap          bitmapToCanvas;

        private CanvasManager   m_CanvasManagerObject;

        private Paint   mBitmapPaint;

        public DrawView(Context context)
        {
            super(context);
            setFocusable(true);
            setFocusableInTouchMode(true);      
            this.setOnTouchListener(this);

            onCanvasInitialization();
        }    

        public void onCanvasInitialization()
        {
            m_Paint = new Paint(Paint.DITHER_FLAG);
            m_Paint.setAntiAlias(true);
            m_Paint.setDither(true);
            m_Paint.setColor(Color.parseColor("#37A1D1"));
            m_Paint.setStyle(Paint.Style.STROKE);
            m_Paint.setStrokeJoin(Paint.Join.ROUND);
            m_Paint.setStrokeCap(Paint.Cap.ROUND); …
Run Code Online (Sandbox Code Playgroud)

android canvas draw erase

2
推荐指数
1
解决办法
1万
查看次数

FadeIn和FadeOut冲突的Jquery

我试图在点击h1标签时显示段落.当用户单击h1时,段落显示,但是当我单击h1时段落显示并且当我再次单击它时隐藏它,但是当我再次执行相同的操作时,淡入和淡出效果同时起作用.

这是我的JSFIDDLE示例:https://jsfiddle.net/9pLnkqz8/

这是我的HTML:

    <h1>REVEAL</h1>
            <p>
                Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
                cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
                proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
            </p>
Run Code Online (Sandbox Code Playgroud)

这是我的JQUERY:

 (function(){

        $('p').hide(); …
Run Code Online (Sandbox Code Playgroud)

javascript jquery

1
推荐指数
1
解决办法
125
查看次数