I have a question to get all deleted items to a new list and also for the changed items. I'm using a datagridview with a sortable bindingsource. For all new items it's already working(last part of the code)
Thanks!
namespace Levelapp
{
public partial class LevelView : Form
{
FilterLevel m_filterLevel;
int m_filterLevelTotal;
public LevelView()
{
InitializeComponent();
}
public LevelView(FilterLevel opt)
{
InitializeComponent();
m_filterLevel = opt;
bindingSource1.DataSource = typeof(LevelResource);
dataGridView1.DataSource = bindingSource1;
bindingSource1.DataSource = m_filterLevel.FoundLevels;
m_filterLevelTotal = bindingSource1.Count;
}
private void newSheet_Click(object sender, EventArgs e)
{
string newItemName = "Sheet" + " " + "1";
string newItemNumber = "A-00";
LevelResource newItem = new LevelResource();
newItem.Name = newItemName;
newItem.Number = newItemNumber;
bindingSource1.Add(newItem);
}
private void deleteSheet_Click(object sender, EventArgs e)
{
bindingSource1.RemoveCurrent();
}
private void ok_Click(object sender, EventArgs e)
{
for (int i = m_filterLevelTotal; i < bindingSource1.Count; i++)
{
bindingSource1.Position = i;
LevelResource newSheet = bindingSource1.Current as LevelResource;
}
}
}
}
Thanks for the quick response. But i get an Error at the bool result line. This code will be used in Revit. Below the part how i put your code under the deleteSheet button
private void deleteSheet_Click(object sender, EventArgs e)
{
for (int i = 0; i < bindingSource1.Count; i++)
{
bindingSource1.Position = i;
var view = bindingSource1.Current as DataRowView;
bool result = view.Row.RowState == DataRowState.Added || view.Row.RowState == DataRowState.Unchanged;
if (result)
{
// new or didn't modified, work as normal
}
else
{
// add to another list
}
}
}