-1

I want my program instead of selecting the whole sentence for a return, that a part of sentence is also possible if a copied that.

here's my code:

protected override void WndProc(ref Message m)
{
    base.WndProc(ref m);

    //check if current operation is a clipboard
    if (m.Msg == WM_DRAWCLIPBOARD)
    {
        //then we use a try catch block so if 
        //anything wrong happens in Clipboard.GetText() our program wont crash
        try
        {
            //with foreach we go through all our questions
            foreach (string question in questionList)
            {
                //and we check if clapboarded text is matches with our question
                if (Clipboard.GetText() == "When a computer is being assembled, which action can be taken to help eliminate cable clutter within a computer case?")
                {
                    notifyIcon1.Icon = SystemIcons.Exclamation;
                    notifyIcon1.BalloonTipTitle = "When a computer is being assembled, which action can be taken to help eliminate cable clutter within a computer case?";
                    notifyIcon1.BalloonTipText = "Install a modular power supply.*";
                    notifyIcon2.BalloonTipIcon = ToolTipIcon.Error;
                    notifyIcon1.ShowBalloonTip(100);
                    return;
                }

this is the question: "When a computer is being assembled, which action can be taken to help eliminate cable clutter within a computer case?"

i want for example if you copied this: When a computer is being assembled, which

You get the same match and the same notification

Thanks in advance

YakovL
  • 7,557
  • 12
  • 62
  • 102
  • Please do your best to clarify what do you expect to happen in which case and what actually happens. For now, the question sounds very unclear. Best regards – YakovL Oct 01 '18 at 14:54

1 Answers1

1

Use string method .Contains() instead of equality comparison.

if (Clipboard.GetText().Contains(yourString))
kaffekopp
  • 2,551
  • 6
  • 13