Private
Dim ts() As Control = Me.ReportViewer1.Controls.Find("toolStrip1", True)
If ts IsNot Nothing ThenDim tsItem As ToolStrip = DirectCast(ts(0), ToolStrip)
Dim sep As New ToolStripSeparator
Dim Lab As New ToolStripLabel
Dim tscbo As New ToolStripComboBox
Dim tboxcbo1 As New ArrayList
tboxcbo1.Add(New mmtypevalues(0, "Todos"))
tboxcbo1.Add(New mmtypevalues(1, "Not Used"))
tboxcbo1.Add(New mmtypevalues(2, "Mandatory"))
tboxcbo1.Add(New mmtypevalues(3, "Supplied"))
tboxcbo1.Add(New mmtypevalues(4, "Optional"))
sep.Name = "sep1"
sep.Alignment = ToolStripItemAlignment.Left
Lab.Name = "Lab01"
Lab.Alignment = ToolStripItemAlignment.Left
tscbo.Alignment = ToolStripItemAlignment.Left
With tscbo.ComboBox
.Name = "pmtsComboBox1"
.BackColor = Color.Green
.ForeColor = Color.White
.BindingContext = Me.BindingContext
ValueMember = "Value"
.DisplayMember = "Display"
.DataSource = tboxcbo1
End With
tsItem.Items.Add(sep)
tsItem.Items.Add(Lab)
tsItem.Items.Add(tscbo)
AddHandler tscbo.ComboBox.SelectedIndexChanged, AddressOf pmtsComboBox1SIC
End If
The handler detects the selectedindexchange, but I do'nt know how to access the selectedindex of
the toolstripcombobox created
Can anyone help
anas fawziPosted Nov 27, 2012, 1:40 PM
c# example
1-add combobox to toolstrip
ToolStripComboBox MyCombo= new ToolStripComboBox();
foreach (Control ctrl in crystalReportViewer1.Controls)
{
if (ctrl is System.Windows.Forms.ToolStrip)
{
//ToolStripComboBox combobox = new ToolStripComboBox();
combobox.Items.Add("ds");
combobox.Items.Add("fd");
((ToolStrip)ctrl).Items.Add(combobox);
combobox.ComboBox.SelectedIndexChanged += MyCombo_SelectedIndexChanged;
}
}
2-access toolstripcombobox SelectedIndexChanged event
private void MyCombo_SelectedIndexChanged(object sender, EventArgs e)
{
string s = MyCombo.SelectedItem.ToString();
}
regards
Anas