public partial class ChangerForm : Form
    {
        public ChangerForm()
        {
            InitializeComponent();
            this.find.Focus();
        }
 
        List<ObjectId> ent = new List<ObjectId>();
 
        private void ButtonFind_Click(object sender, EventArgs e)
        {
            infoList.Items.Clear();
            
            int l = 0, ll = 0, imt=0, iot=0, iml=0;
            Document doc = App.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
 
            using (DocumentLock dl = doc.LockDocument())
            {
                using (Transaction tr = doc.TransactionManager.StartTransaction())
                {
                    BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                    DBDictionary dbl = tr.GetObject(db.LayoutDictionaryId, OpenMode.ForRead) as DBDictionary;
 
                    if (allSpace.Checked) ll = dbl.Count-1;
                    else if (inModel.Checked) ll = 0;
                    else if (inLauouts.Checked && ++l == 1) ll = dbl.Count-1;
 
                    List<ObjectId> item = new List<ObjectId>();
                    foreach (DBDictionaryEntry dblay in dbl) item.Add(dblay.Value);
 
                    for (int i = l; i <= ll; i++)
                    {
                        Layout lay = tr.GetObject(item[i], OpenMode.ForRead) as Layout;
                        BlockTableRecord btlay = tr.GetObject(lay.BlockTableRecordId, OpenMode.ForRead) as BlockTableRecord;
                        
                        foreach (ObjectId obid in btlay)
                        {
                            object obj = obid.GetObject(OpenMode.ForRead);
                            if (obj is MLeader)
                            {
                                MLeader ml = obj as MLeader;
                                if (ml.MText.Text.IndexOf(find.Text) >= 0 && (skip.Text == "" || ml.MText.Text.IndexOf(skip.Text) == -1))
                                {                                    
                                    ent.Add(obid);
                                    infoList.Items.Add(new ListViewItem(new[] { lay.LayoutName, "Выноска", ml.MText.Text }));
                                }
                            }
                        }
 
                    }
                    tr.Commit();
                }
            }
        }
 
        private void ChangeHand_Click(object sender, EventArgs e)
        {
            Document doc = App.DocumentManager.MdiActiveDocument;
 
            using (DocumentLock dl = doc.LockDocument())
            {
                using (Transaction tr = doc.TransactionManager.StartTransaction())
                {
                    var k = infoList.SelectedIndices;
 
                    MLeader ol = ent.ElementAt(k[0]).GetObject(OpenMode.ForWrite) as MLeader;
 
                    ol.MText.Contents = ol.MText.Text.Replace(find.Text, need.Text);
 
                    tr.Commit();
                }
            }
        }
}