10933 : Why does the GTP.net OnTimeItemAreaKeyDown event neverfire?

< ?xml:namespace prefix = o />Question

 

Why does the GTP.net OnTimeItemAreaKeyDown event never fire?< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

I need detect “< ?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />del” key and delete TimeItemLinks.Select SelectedLink

 

Answer

 

This event only fires if a control has Focus, and default we do not give keyboard focus to the time item area since it takes focus from the grid (this may very well change in the future when we implement key navigation i the time items)

 

The workaround is to give focus to the TimeItemArea in the MouseDown event:

 

   private void gantt1_OnTimeItemAreaMouseDown(object sender, MouseEventArgs e)
    {
      gantt1.TimeItemArea.Focus();
    }
 
    private void gantt1_OnTimeItemAreaKeyDown(object sender, KeyEventArgs e)
    {
      MessageBox.Show(“key down”);

    }

 

10938 : The problem I have found is that my OnTimeItemAreaKeyDown event is not firing correctly…

Question

I have been using GTP.Net for a long time now in one of my apps. I just recently added the feature to move next or previous in the timeitems on the screen.

< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 

The problem I have found is that my OnTimeItemAreaKeyDown event is firing correctly, but only when I use my numeric pad left (4) or right (6).

 

If I use the regular left and right keys on my keyboard, the control does not seem to pick up the event has fired.

 

I have other controls on my form and they receive the left and right keys, but my GTP doesn’t.

 

Is there something I need to enable to make the left and right keys work?

Answer

I am not sure why some of your keys are working, I would have guessed that all or nothing should apply.

The main “GotYou” thing about catching keys in the time item area is to focus the time item area for key-input.

Implement a MouseDownEvent:

private void gantt1_OnTimeItemAreaMouseDown(object sender, MouseEventArgs e)
{
  gantt1.TimeItemArea.Focus();
}

Try again, this will now work as expected:

private void gantt1_OnTimeItemAreaKeyDown(object sender, KeyEventArgs e)
{
  label1.Text =
“DOWN “ + e.KeyValue.ToString();
}