Questions re DataGrid

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff Cook

    #1

    Questions re DataGrid

    Hi

    1. In a DataGrid, I'd like to respond to a click anywhere on the line,
    but it seems that the click event only works on the first column (the
    "indicator" column).

    2. In my click event, I want to get data from the correct row of the
    DataSet (XML). This what I've done so far, and I realise that I have
    specifically asked for row zero, but I can't see how to specify the
    "current" row.

    private void grdLandlords_Cl ick(object sender, System.EventArg s e)
    {
    frmLandlord f = new frmLandlord();
    f.Text = "Landlord "
    + (string) ds.Tables["Landlord"].Rows[0]["LandlordCo de"]
    + " "
    + (string) ds.Tables["Landlord"].Rows[0]["SortKey"];
    f.Show();
    } // eventually, I'll pass the LandlordCode and assign f.Text from within
    the form - if I can work out how to access my main form DataSet!

    TIA

    Jeff


  • Dmitriy Lapshin [C# / .NET MVP]

    #2
    Re: Questions re DataGrid

    Hi Jeff,
    [color=blue]
    > 1. In a DataGrid, I'd like to respond to a click anywhere on the line,
    > but it seems that the click event only works on the first column (the
    > "indicator" column).[/color]

    Play with the MouseDown/MouseUp events. These work OK for me.
    [color=blue]
    >
    > 2. In my click event, I want to get data from the correct row of the
    > DataSet (XML). This what I've done so far, and I realise that I have
    > specifically asked for row zero, but I can't see how to specify the
    > "current" row.[/color]

    CurrencyManager cm = (CurrencyManage r)theForm.Bindi ngContext[
    theGrid.DataSou rce, theGrid.DataMem ber];

    DataView theView = (DataView)cm.Li st;
    DataRow currentRow = theView[cm.Current].Row;

    Hope this helps.

    --
    Dmitriy Lapshin [C# / .NET MVP]
    X-Unity Test Studio

    Bring the power of unit testing to VS .NET IDE

    "Jeff Cook" <jeffcATaspectD OTcoDOTnz> wrote in message
    news:%23nK5OJpd DHA.1752@TK2MSF TNGP11.phx.gbl. ..[color=blue]
    > Hi
    >
    > 1. In a DataGrid, I'd like to respond to a click anywhere on the line,
    > but it seems that the click event only works on the first column (the
    > "indicator" column).
    >
    > 2. In my click event, I want to get data from the correct row of the
    > DataSet (XML). This what I've done so far, and I realise that I have
    > specifically asked for row zero, but I can't see how to specify the
    > "current" row.
    >
    > private void grdLandlords_Cl ick(object sender, System.EventArg s e)
    > {
    > frmLandlord f = new frmLandlord();
    > f.Text = "Landlord "
    > + (string) ds.Tables["Landlord"].Rows[0]["LandlordCo de"]
    > + " "
    > + (string) ds.Tables["Landlord"].Rows[0]["SortKey"];
    > f.Show();
    > } // eventually, I'll pass the LandlordCode and assign f.Text from within
    > the form - if I can work out how to access my main form DataSet!
    >
    > TIA
    >
    > Jeff
    >
    >[/color]

    Comment

    Working...