title: SAP Business One Automatic Row numbering for Matrix
body: <p>I am making an add-on for SAP B1 8.82. I would like automatic row numbering for my matrix column &quot;#&quot; i.e. UID &quot;V_-1&quot;. Is there a feature in 8.82 that can help me do this?</p>
  <p>I am using UserDataSource for my matrix. How do I get to have row numbers that automatically update when I add/remove a row?</p>
  <p>I have the following added to menu event 1292 for adding row numbers manually but cant get it to work for row deletion - menu event 1293. (Using C#)</p>
  <pre><code>case &quot;1292&quot;://Add Matrix Row
                      _form.Freeze(true);
                      _form.DataSources.UserDataSources.Item(&quot;itemNo&quot;).Value = &quot;&quot;;
                      _form.DataSources.UserDataSources.Item(&quot;itemDesc&quot;).Value = &quot;&quot;;
                      _form.DataSources.UserDataSources.Item(&quot;quantity&quot;).Value = &quot;&quot;;
                      _form.DataSources.UserDataSources.Item(&quot;warehouse&quot;).Value = &quot;&quot;;
                      _form.DataSources.UserDataSources.Item(&quot;distrRule&quot;).Value = &quot;&quot;;
                      _form.DataSources.UserDataSources.Item(&quot;project&quot;).Value = &quot;&quot;;
                      oMatrixItem.AddRow();
  
                      // row numbering   
                      int i = 1;
                      int j = 0;
                      j = oMatrixItem.RowCount;
  
                      while (j &gt;= i)
                      {
                          oMatrixItem.Columns.Item(&quot;V_-1&quot;).Cells.Item(i).Specific.Value = i.ToString();
                          i = i + 1;
                      }
  
                      _form.Freeze(false);
                      break;
  </code></pre>