Hi!
I learn programming for Microstation with use C#. And I have small problem with levels.
I have a 3 procedures:
1. Update DataGridView with level's informations.
2. Initialize Component.
3. Update Button Click.
But I have problem with this code. After rename level I press button Update (button2_Click), but in my LevelsGrid i see old name.
What am I doing wrong?
public void UpdateLevelsGrid() { LevelsGrid.RowCount = 1; MSApp.ActiveModelReference.Levels.Rewrite(); BCOM.Levels myLevels = MSApp.ActiveModelReference.Levels; int UsedLevelsCount = 0; int LevelsWithPolygonsCount = 0; for (int i = 1; i <= myLevels.Count; i++) { int ElementsCount = 0; int PolygonsCount = 0; LevelsGrid.Rows.Add(myLevels[i].Number, myLevels[i].Name, ElementsCount, PolygonsCount); } }
public SamplePoints() { InitializeComponent(); MSApp = BMI.Utilities.ComApp; UpdateLevelsGrid(); }
private void button2_Click(object sender, EventArgs e) { UpdateLevelsGrid(); }
Hi Maxim,
Unknown said:public void UpdateLevelsGrid()
public
void
UpdateLevelsGrid()
Why do you use MSApp.ActiveModelReference.Levels.Rewrite(); there? I see no reason for it.
MSApp.ActiveModelReference.Levels.Rewrite();
Unknown said:After rename level
Rename where? In Level Manager dialog?
Unknown said:I press button Update
It's not necessary to update the grid manually. You can use LevelChanged event to monitor level modifications automatically.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point