Hello,
I have a question how to get data to a winfrom that is using a Datagridview.
I have the following code that is working to collect the Level info, see below:
But how can you simply display the collected info to the Datagridview? because it's not a public value that you can use with
Datagridview.DataSource= levelDataSourceRow
Thanks!
namespace Getlevel { [Transaction(TransactionMode.Manual)] public class LevelInfo : IExternalCommand { public Result Execute (ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; Transaction documentTransaction = new Transaction(doc, "Document"); documentTransaction.Start(); { try { FilteredElementCollector collector = new FilteredElementCollector(doc); ICollection<Element> collection = collector.OfClass(typeof(Level)).ToElements(); foreach (Element e in collection) { Level level = e as Level; LevelData levelDataSourceRow = new LevelData(); levelDataSourceRow.LevelID = level.Id.IntegerValue; levelDataSourceRow.Naam = level.Name; levelDataSourceRow.Hoogte = level.Elevation; } using (InfoLevel displayform = new InfoLevel(commandData)) { displayform.ShowDialog(); } } catch (Exception ex) { message = ex.Message; documentTransaction.RollBack(); return Autodesk.Revit.UI.Result.Failed; } documentTransaction.Commit(); return Autodesk.Revit.UI.Result.Succeeded; } } } }
Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
Put the data into an intermediary container that you can use as a data source.
Here is a sample that does just that:
http://thebuildingcoder.typepad.com/blog/2012/05/the-schedule-api-and-access-to-schedule-data.html
Cheers,
Jeremy
Can't find what you're looking for? Ask the community or share your knowledge.