Populate same value across column

Posted by: maneesh on 8 September 2017, 1:23 pm EST

  • Posted 8 September 2017, 1:23 pm EST

    <p>I have a hierarchical view (depth = 2).</p><p>In the child view, when somebody changes a value in a row, I want the same value to be reflected across all cells in the column of the child view.</p><p>Any ideas of what approach I can take for accomplishing this?</p><p>The grid is bound to a strongly typed dataset (2 tables, related), which is how I get the hierarchical view.  If I go through the strongly typed DataSet, and call</p><p>ds.GetChanges(), that only gives me a DataTable containing changed rows.  Is there any way I can find out what columns of a changed row were changed? <br></p>
  • Replied 8 September 2017, 1:23 pm EST

    <P>Hello,</P>
    <P>I used code like the following to catch the Change event and populate the rest of the rows in the changed column in the changed child sheet with the changed value.</P><FONT size=2>
    <P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Private</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub</FONT></FONT><FONT size=2> FpSpread1_Change(</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT size=2> sender </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Object</FONT></FONT><FONT size=2>, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT size=2> e </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> FarPoint.Win.Spread.ChangeEventArgs) </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Handles</FONT></FONT><FONT size=2> FpSpread1.Change</P>
    <P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>For</FONT></FONT><FONT size=2> i </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Integer</FONT></FONT><FONT size=2> = e.Row + 1 </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>To</FONT></FONT><FONT size=2> e.View.Sheets(0).RowCount - 1</P>
    <P>e.View.Sheets(0).SetValue(i, e.Column, e.View.Sheets(0).GetValue(e.Row, e.Column))</P>
    <P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Next</P></FONT></FONT><FONT size=2>
    <P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>End</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub</FONT></FONT></P>
    <P>There is not a way to find the changed columns from the bound DataSource. You can only get the changed rows like you are.</P>
  • Replied 8 September 2017, 1:23 pm EST

    <p>The method works perfectly to change the values on the grid.</p><p>However, the underlying row bound to the changed column is not market dirty, which is why I cannot see the changes to the bound DataTable (even if I click somewhere else in the grid)<br></p><p>Any workaround? <br></p>
  • Replied 8 September 2017, 1:23 pm EST

    <p>I'm going to answer my own question.  This is a snippet of code I've used in , based on an earlier post:</p><p>private void fpSpreadEditInc_Change(object sender, ChangeEventArgs e)</p><p> { <br></p><p>            if (e.Row == 0)<br>            {<br>                //If things are changed for the first row, I want the same value to be reflected to all columns in the expanded ChildView<br><br>                for (int i = e.Row + 1; i < e.View.Sheets[0].RowCount; i++)<br>                {<br>                    e.View.Sheets[0].SetValue(i, e.Column, e.View.Sheets[0].GetValue(e.Row, e.Column));</p><p>                    //Find out some values to identify the row in DataTable which needs to change<br></p><p>                    int iRgnNum = Convert.ToInt32(e.View.Sheets[0].GetValue(i, 0));<br>                    int modelID = Convert.ToInt32(e.View.Sheets[0].GetValue(i, 1));<br>                    string sFilterExpr = string.Format("ModelID = {0} AND RgnNum = {1}", modelID, iRgnNum);<br><br>                    DataRow[] rowsToChange = dataSetIncentives.DataTableIncentives.Select(sFilterExpr);</p><p>                    //Now call EndInit() on the found row (there will only be 1 in my case) <br></p><p>                    rowsToChange[0].EndEdit();<br>                }<br>            }</p><p>} <br></p>
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels