Glossary Item Box
This walkthrough is made up of the following activity:
To write the code in Visual Basic
To write the code in C#
The following example shows what the code for the method looks like.
' Visual Basic
Private Sub selChangePropGrid()
cnt = Me.Designer1.Selection.Count - 1
Dim selectedControls(cnt) As Object
Try
For i = 0 To Me.Designer1.Selection.Count - 1
selectedControls.SetValue(CType(Me.Designer1.Selection(i), Object), i)
Next
Me.PropertyGrid1.SelectedObjects = selectedControls
Catch ex As Exception
MessageBox.Show(Me, ex.Message + ": " + ex.Source + ": " + ex.StackTrace, _ "Selection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
//C#
private void selChangePropGrid(){int cnt = this.designer1.Selection.Count;
System.Object[] selectedControls = new object[cnt];
try
{
for(int i=0;i<this.designer1.Selection.Count;i++)
{
selectedControls.SetValue((System.Object)this.designer1 .Selection[i],i);
}
this.propertyGrid1.SelectedObjects = selectedControls;
}
catch(Exception ex)
{
MessageBox.Show(this,ex.Message + ": " + ex.Source + ": " + ex.StackTrace,
"Selection Error",MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
See Also |
Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.