Your 'for' loop ending condition is incorrect - the C# equivalent is:
for (i = 0; i < BdsTabelle.Count; i++)
or
for (i = 0; i <= BdsTabelle.Count - 1; i++)
Question
Hi guys I have the following code in vb.net (framework 4.5)
Private Sub CaricaComboTabelle()
Dim i As Integer
BdsTabelle.Filter = "TABLE_TYPE='TABLE'"
cmbTabelle.Items.Clear()
For i = 0 To BdsTabelle.Count - 1
cmbTabelle.Items.Add(BdsTabelle.Current("TABLE_NAME"))
cmbTabelle.Items.Add(BdsTabelle.Current("TABLE_NAME"))
BdsTabelle.MoveNext()
Next
cmbTabelle.SelectedIndex = 0
End Sub
How can I convert the code in c#? I have tried this:
private void Form1_Load(object sender, EventArgs e)
{
bdsTabelle.Filter = "TABLE_TYPE='TABLE'";
cmbTabelle.Items.Clear();
for (int i = 0; i < bdsTabelle.Count - 1; i++)
{
cmbTabelle.Items.Add(bdsTabelle.IndexOf("TABLE_NAME"));
BdsTabelle.Current["TABLE_NAME"];
bdsTabelle.MoveNext();
}
cmbTabelle.SelectedIndex = 0;
}
But dosen't work because here Current is a property Readonly
My goal is load BdsTabelle.Current("TABELE_NAME")
(that is a BindingSource
in cmbTabelle that is a ComboBox
Solution
Your 'for' loop ending condition is incorrect - the C# equivalent is:
for (i = 0; i < BdsTabelle.Count; i++)
or
for (i = 0; i <= BdsTabelle.Count - 1; i++)
OTHER TIPS
http://www.developerfusion.com/tools/convert/vb-to-csharp/ ---> 95 % right. You have to paste "all" (Importend code like:Imports System.Data.SqlClient and class.... ) of your code to translate it