"Remy Lebeau (TeamB)" <gambi...@yahoo.com> wrote in message
news:3ec199a8$1@newsgroups.borland.com...
Quote
> With all the problems you're having with this lately, it makes me think
you
> are misusing the ListBox incorrectly in the first place. Everything you
> have described so far should be working fine under normal conditions.
What
> are your EXACT settings for the ListBox itself? Are you able to create a
> new project with absolute minimal code that demonstrates the same
problems?
> If so, then please post that project to the .attachments group for us to
> have something to actually look at.
> Gambit
i don't doubt i'm doing something wrong. i tried deleting the listbox and
placing a new one on the settings form but it made no difference, which
means i am doing something wrong.
here's all the code i think is relevant
void __fastcall TSettings_Form::Add_ButtonClick(TObject *Sender)
{
TAddServer_Form *AddServer = new TAddServer_Form(Application);
AddServer->ShowModal();
delete AddServer;
void __fastcall TSettings_Form::Edit_ButtonClick(TObject *Sender)
{
if (Servers_ListBox->ItemIndex > -1) {
TEditServer_Form *EditServer = new TEditServer_Form(Application);
TLocateOptions SearchOptions;
if (Data->Servers_DataSource->DataSet->Locate("ServerName",
Servers_ListBox->Items->Strings[Servers_ListBox->ItemIndex], SearchOptions))
{
for (int i=0;i<EditServer->Type_ComboBox->Items->Count;i++) {
if (EditServer->Type_ComboBox->Items->Strings[i] ==
Data->Servers_DataSource->DataSet->FieldByName("Type")->AsString) {
EditServer->Type_ComboBox->ItemIndex = i;
}
}
EditServer->Address_Edit->Text =
Data->Servers_DataSource->DataSet->FieldByName("ServerAddress")->Value;
EditServer->Username_Edit->Text =
Data->Servers_DataSource->DataSet->FieldByName("Username")->Value;
EditServer->Password_Edit->Text =
Data->Servers_DataSource->DataSet->FieldByName("Password")->Value;
EditServer->ShowModal();
delete EditServer;
}
}
void __fastcall TAddServer_Form::OK_ButtonClick(TObject *Sender)
{
Data->Servers_DataSource->DataSet->Insert();
Data->Servers_DataSource->DataSet->FieldByName("ServerName")->Value =
Address_Edit->Text;
Data->Servers_DataSource->DataSet->FieldByName("ServerAddress")->Value =
Address_Edit->Text;
Data->Servers_DataSource->DataSet->FieldByName("Type")->Value =
Type_ComboBox->Text;
Data->Servers_DataSource->DataSet->FieldByName("Username")->Value =
Username_Edit->Text;
Data->Servers_DataSource->DataSet->FieldByName("Password")->Value =
Password_Edit->Text;
Data->Servers_DataSource->DataSet->Post();
Settings_Form->Servers_ListBox->AddItem(Address_Edit->Text, NULL);
Close();
void __fastcall TEditServer_Form::OK_ButtonClick(TObject *Sender)
{
Data->Servers_DataSource->DataSet->Edit();
Data->Servers_DataSource->DataSet->FieldByName("ServerName")->Value =
Address_Edit->Text;
Data->Servers_DataSource->DataSet->FieldByName("ServerAddress")->Value =
Address_Edit->Text;
Data->Servers_DataSource->DataSet->FieldByName("Type")->Value =
Type_ComboBox->Text;
Data->Servers_DataSource->DataSet->FieldByName("Username")->Value =
Username_Edit->Text;
Data->Servers_DataSource->DataSet->FieldByName("Password")->Value =
Password_Edit->Text;
Data->Servers_DataSource->DataSet->Post();
Settings_Form->Servers_ListBox->Items->Delete(Settings_Form->Servers_ListBox
->ItemIndex);
Settings_Form->Servers_ListBox->AddItem(Address_Edit->Text, NULL);
Close();
i also tried a new application doing the same basic thing and that worked
ok and it i put a tedit in the settings form and just have the add button
add whatever's in the edit into listbox, that works ok too. and there's no
Add() for a tlistbox, only AddItem().
mostuff