Home > Back-end >  Consult a Delphi code into C Builder
Consult a Delphi code into C Builder

Time:09-25

 if (this. ListBox1. SelectedIndex & gt;=0 & amp; & This. The ListBox1. SelectedIndex & lt; ListBox1. Items. The Count - 1) 
{
String name=ListBox1. SelectedItem. Text;
String ID=ListBox1. SelectedItem. Value;
Int index=ListBox1. SelectedIndex;
ListBox1. SelectedItem. Text=ListBox1. Items [index + 1]. The Text;
ListBox1. SelectedItem. Value=https://bbs.csdn.net/topics/ListBox1.Items [index + 1] Value;
ListBox1. Items [index + 1]. The Text=name;
ListBox1. Items [index + 1] Value=https://bbs.csdn.net/topics/ID;
ListBox1. SelectedIndex++;
}

CodePudding user response:

Is to choose the line down line by line in the list box in the end

CodePudding user response:

Change. To - & gt;

CodePudding user response:

· dataxdata
Yes ah, is also found on the web, but I will only in c + + Builder and Delphi code can't copy, can you help me to change?

CodePudding user response:

Ccrun
To change. - & gt; Ah ~ ~ ~

CodePudding user response:

C + + builder will correct some Delphi controls, format very strange, very hemp all that

CodePudding user response:

reference 4 floor fengdos response:
ccrun
To change. - & gt; Error ah ~ ~ ~


What also needless to say, you are still stick the original Delphi code come out,

CodePudding user response:

To change the string AnsiString

CodePudding user response:

////////////////////button mobile ordering 
Private void moveUpListBox (ListBox ListBox1)//move up
{

If (ListBox1 SelectedIndex & gt; 0)
{
Int index=ListBox1. SelectedIndex;
String temp=ListBox1. Items [index - 1]. The ToString ();
ListBox1. Items.] [index - 1=ListBox1 SelectedItem. The ToString (); ;
ListBox1. Items [index]=temp;
ListBox1. SelectedIndex=index - 1;
}
}

Private void moveDownListBox (ListBox ListBox1)//move down
{

If (ListBox1 SelectedIndex & lt; ListBox1. Items. The Count - 1)
{

Int index=ListBox1. SelectedIndex;
String temp=ListBox1. Items [index + 1]. The ToString ();
ListBox1. Items [index + 1]=ListBox1. SelectedItem. The ToString (); ;
ListBox1. Items [index]=temp;
ListBox1. SelectedIndex=index + 1;
}
}

//up
Private void button3_Click (object sender, EventArgs e)
{
MoveUpListBox (listBox1);

}
//down
Private void button4_Click (object sender, EventArgs e)
{
MoveDownListBox (listBox1);
}

CodePudding user response:

No one help me??

CodePudding user response:

Is this your c # code, not the Delphi code, implemented in c + + Builder can be like this:
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
//move up
Void __fastcall TForm1: : Button1Click (TObject * Sender)
{
If (ListBox1 - & gt; ItemIndex & lt; 0) return;

Int newIndex=ListBox1 - & gt; ItemIndex & lt; 1? Zero: ListBox1 - & gt; ItemIndex - 1;
ListBox1 - & gt; The Items - & gt; Exchange (ListBox1 - & gt; ItemIndex newIndex);
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//move down
Void __fastcall TForm1: : Button2Click (TObject * Sender)
{
If (ListBox1 - & gt; ItemIndex & lt; 0) return;

Int newIndex=ListBox1 - & gt; ItemIndex & gt;=ListBox1 - & gt; The Items - & gt; The Count - 1?
ListBox1 - & gt; The Items - & gt; The Count - 1: ListBox1 - & gt; ItemIndex + 1;
ListBox1 - & gt; The Items - & gt; Exchange (ListBox1 - & gt; ItemIndex newIndex);
}

CodePudding user response:

Thank you very much for the moderator ccrun, my problem solved
  • Related