1

現在、グリッド項目をダブルクリックすると、以下のイベントが発生します。これには、ヘッダーをダブルクリックした場合も含まれます。

クリックされたヘッダーまたは行を区別する方法はありますか? SelectedItem の位置は常に > 0

this.grdItems = new Janus.Windows.GridEX.GridEX();
...
this.grdItems.DoubleClick += new System.EventHandler(this.grdItems_DoubleClick);

private void grdItems_DoubleClick(object sender, System.EventArgs e)
    { 
        if (grdItems.SelectedItems!=null && grdItems.SelectedItems[0].Position >= 0)
        {
          //doing something
        }
    }
4

2 に答える 2

0

メソッドを使うのもひとつのHitTest()方法

変数を宣言する

public int MLastX { get; set; }
public int MLastY { get; set; }

最後のマウス クリックの座標を取得する方法を用意する

/// <summary>
/// Handles the MouseDown event of the grdSearch control. On a mousedown the click co-ordinates
///  is set.  This method is used to determine whether you have clicked on a gridrow cell in the method above
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
private void grdSearch_MouseDown(object sender, MouseEventArgs e)
{
    MLastX = e.X;
    MLastY = e.Y;
}

そのクリックがセル内にあるかどうかを確認します

//check whether you have clicked in a cell 
if (grdSearch.HitTest(MLastX, MLastY) == GridArea.Cell)
{
   //now only execute the rest
}
于 2016-09-26T07:36:55.917 に答える