Message 1 of 1
Append listbox C#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
private void btnEkle_Click(object sender, EventArgs e)
{
this.Hide();
{
var typeValueArray = new Adb.TypedValue[]
{
new Adb.TypedValue((int)Adb.DxfCode.Operator, "<or"), // start ORing
new Adb.TypedValue((int)Adb.DxfCode.Start, "Text"),
new Adb.TypedValue((int)Adb.DxfCode.Start, "MText"),
new Adb.TypedValue((int)Adb.DxfCode.Operator, "or>"), // end ORing
// to get any ACAD Obj dxf name (Text, MText , ...) use ACAD LIST command.
};
SelectionFilter filter;
if (chcBKirmizi.Checked == true)
{
filter = new SelectionFilter(new[] { new Adb.TypedValue(0, "TEXT"), new Adb.TypedValue(62, 1) });
}
else
{
filter = new SelectionFilter(new[] { new Adb.TypedValue(0, "TEXT"), new Adb.TypedValue(1, TxtSecimkriter.Text) });
}
var selectionOptions = new PromptSelectionOptions()
{
MessageForAdding = "select texts",
};
var selectionResult = Adoc.Editor.GetSelection(selectionOptions, filter);
if (selectionResult.Status != PromptStatus.OK)
{
Adoc.Editor.WriteMessage($"\n----- Seçilecek Obje Bulunamadı.! ------");
return;
}
var allTextIDs = selectionResult.Value.GetObjectIds();
List<string> allText = new List<string>();
using (var ts = Adb.HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
{
Type type;
foreach (var id in allTextIDs)
{
var dbObj = id.GetObject(Adb.OpenMode.ForRead);
type = dbObj.GetType();
if (type.Equals(typeof(Adb.DBText)))
{
if (chcbPoz.Checked)
{
allText.Add(allText.Count + 1 + " " + ((Adb.DBText)dbObj).TextString);
}
else
{
allText.Add(((Adb.DBText)dbObj).TextString);
}
}
else if (type.Equals(typeof(Adb.MText)))
{
allText.Add(((Adb.MText)dbObj).Text);
}
}
}
lblListCount.Visible = true;
listBox1.DataSource = allText;
lblListCount.Text = "Toplam: " + listBox1.Items.Count.ToString();
this.Show();
}
}
Hello
How can we continue to add data to the listbox with checkbox control?
If the checkbox is checked, you can add data.
Thanks.