Board index » cppbuilder » TComboBox at Runtime

TComboBox at Runtime


2005-01-14 09:39:02 PM
cppbuilder11
Hi,
I got a StringGrid in my Application, and i would like to Show a ComboBox at
the top of the cell, when a cell in col 3 is clicked. i tried this:
TComboBox *temp_CB=NULL;
if( Reftab_SG->Col != 3)
{
ModeHinweis_Mem->Hide(); // HinweisPanel für Mode verstecken
if (temp_CB)
delete temp_CB; temp_CB=NULL;
}
else
{
ModeHinweis_Mem->Show(); // HinweisPanel für Mode anzeigen
if (lan)
{
[someCode]
}
else
{
[some Code]
}
temp_CB=new TComboBox(Reftab_SG);
temp_CB->Left=200;
temp_CB->Top=200;
temp_CB->Visible=true;
}
but i can't see anything, why?
Thanks!
 
 

Re:TComboBox at Runtime

Ron Eggler @ Work wrote:
Quote
Hi,

I got a StringGrid in my Application, and i would like to Show a
ComboBox at the top of the cell, when a cell in col 3 is clicked. i
tried this:

TComboBox *temp_CB=NULL;
if( Reftab_SG->Col != 3)
{
ModeHinweis_Mem->Hide(); // HinweisPanel für Mode verstecken
if (temp_CB)
delete temp_CB; temp_CB=NULL;
}
else
{
ModeHinweis_Mem->Show(); // HinweisPanel für Mode anzeigen
if (lan)
{
[someCode]
}
else
{
[some Code]
}
temp_CB=new TComboBox(Reftab_SG);
temp_CB->Left=200;
temp_CB->Top=200;
temp_CB->Visible=true;
}

but i can't see anything, why?
Thanks!
Ok, got it displayed, but i don't get it hided anymore :( my code now:
TComboBox *temp_CB=NULL;
if( Reftab_SG->Col != 3)
{
ModeHinweis_Mem->Hide(); // HinweisPanel für Mode verstecken
if (temp_CB)
{
temp_CB->Visible=false;
delete temp_CB; temp_CB=NULL;
}
}
else
{
ModeHinweis_Mem->Show(); // HinweisPanel für Mode anzeigen
if (lan)
{
[someCode]
}
else
{
[someCode]
}
temp_CB=new TComboBox(this);
temp_CB->Parent=this;
temp_CB->Style=csDropDownList;
temp_CB->OnChange = temp_CBChange;
temp_CB->Left=Reftab_SG->Left;
temp_CB->Height=Reftab_SG->DefaultRowHeight;
temp_CB->Top=Reftab_SG->Top;
temp_CB->Visible=true;
temp_CB->Items->Add("Bit 1&0: 0=Speedmode, 1=absolute Pos. mode,
2=relative Pos. mode");
temp_CB->Items->Add("Bit 4: 1=Absolute Time(whole mov. Cmd), 0=Time
after mov. Cmd");
temp_CB->Items->Add("Bit 5: 1=Stop after this mov. Cmd, 0=Continue
with next mov. Cmd");
/*** [Code for positioning] ***/
TRect Rect = Reftab_SG->CellRect(Reftab_SG->Col,Reftab_SG->Row);
temp_CB->Top = Reftab_SG->Top;
temp_CB->Left = Reftab_SG->Left;
temp_CB->Text = EmptyStr;
temp_CB->Top = temp_CB->Top + Rect.Top + Reftab_SG->GridLineWidth+72;
temp_CB->Left = temp_CB->Left + Rect.Left +
Reftab_SG->GridLineWidth+8;
temp_CB->Height = (Rect.Bottom - Rect.Top);
temp_CB->Width = (Rect.Right - Rect.Left) + 2;
temp_CB->Visible = true;
temp_CB->SetFocus();
/*** [/Code for positioning] ***/
}
Where is the Error, what do i miss?
Thanks!
 

Re:TComboBox at Runtime

Ron Eggler @ Work wrote:
Quote
Ok, got it displayed, but i don't get it hided anymore :( my code now:
Why did you post the wrong code again ? Please trim quotes.
Quote
Where is the Error, what do i miss?
There is no code that tries to hide the TComboBox.
If you want quick help than post codesnippets that will work
when someone puts a TStringGrid and two TButtons on a TForm.
Do not change the names given by the IDE.
Hans.
 

{smallsort}

Re:TComboBox at Runtime

Hans Galema wrote:
Quote
Ron Eggler @ Work wrote:

>Ok, got it displayed, but i don't get it hided anymore :( my code
>now:

Why did you post the wrong code again ? Please trim quotes.
yes sorry...
Quote
>Where is the Error, what do i miss?

There is no code that tries to hide the TComboBox.
sure there is:
temp_CB->Visible=false;
Quote

If you want quick help than post codesnippets that will work
when someone puts a TStringGrid and two TButtons on a TForm.

Do not change the names given by the IDE.
sure do i change 'em. i've visited an OO-course and the teacher there told
us, we should give names,to draw direct conclusions from.
Quote

Hans.
roN
 

Re:TComboBox at Runtime

"Ron Eggler @ Work" < XXXX@XXXXX.COM >wrote in message
Quote
I got a StringGrid in my Application, and i would like to Show
a ComboBox at the top of the cell, when a cell in col 3 is clicked.
i tried this:
Which version of BCB are you actually using? If BCB6, then the VCL already
has native support for what you are trying to accomplish manually. Simply
derive a new component from TStringGrid and override the CreateEditor()
method to return an instance of TInplaceEditList rather than the default of
TInplaceEdit. Also assign an event handler to the
TInplaceEditList::OnGetPickListItems event so that you can fill in the
drop-down list when needed.
If you are not using BCB6, then you can derive your own class from
TInplaceEdit to handle your ComboBox, and then the above still applies.
Gambit
 

Re:TComboBox at Runtime

Remy Lebeau (TeamB) wrote:
Quote
"Ron Eggler @ Work" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>I got a StringGrid in my Application, and i would like to Show
>a ComboBox at the top of the cell, when a cell in col 3 is clicked.
>i tried this:

Which version of BCB are you actually using? If BCB6, then the VCL
already has native support for what you are trying to accomplish
manually. Simply derive a new component from TStringGrid and
override the CreateEditor() method to return an instance of
TInplaceEditList rather than the default of TInplaceEdit. Also
assign an event handler to the TInplaceEditList::OnGetPickListItems
event so that you can fill in the drop-down list when needed.

If you are not using BCB6, then you can derive your own class from
TInplaceEdit to handle your ComboBox, and then the above still
I'm using BCB 5. and how would your Version work exactly? Don't understand
that.
Got it to work with perevious posted Code but the TComboBoxes don't
disappear anymore. :(
Quote
applies.


Gambit