I'm try to get the keypad subtract key to work the same way as the main
minus key on columns in a winform datagrid. To do this, I've overridden the
DataGrid's ProcessKeyPreview method. In the method, I change the params to
ones that come in when the minus key (above the main keyboard) is in the
message. But, for some reason this doesn't work. I thought that with the
Message being passed by reference, I could make any changes I needed to on
it.

protected unsafe override bool ProcessKeyPreview(ref Message m) {
    if (m.WParam.ToInt32() == 109) {
        m.WParam = new IntPtr(189);
        m.LParam = new IntPtr(786433);
        m.Msg = 256;
    }
    return base.ProcessKeyPreview(ref m);
}

BTW, I'm setting the LParam and Msg temporarily, just until I get it
working. Then I do plan on ORing with the correct flags in the LParam.

If there is a better way, I would like to know it, as with this method, I
have to allow unsafe code. But, why doesn't this work?

Thanks,
Erick

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to