Jump to content
Sign in to follow this  
IElite

Overriding TW3ListBoxItemData style

Recommended Posts

@lennart, @jarto

Testing the latest update, I am trying to override the TW3ListBoxItemData's "RemoveSelectedStyle" and "SetSelectedStyle" methods.

However,  I can't seem to get the StyleClass property to work. However, I can do color changes at runtime.

 

procedure TXListBoxItemData.RemoveSelectedStyle;
begin
  //TXListBoxItem(ItemObject).StyleClass:= 'XListBoxItemStyle';  //does not work
  //TXListBoxItem(ItemObject).Label.StyleClass:= 'XListBoxItemStyle'; //does not work

  TXListBoxItem(ItemObject).Label.Color:= clWhite;  //works
  TXListBoxItem(ItemObject).Label.Font.Color:= clBlack; //works
end;

procedure TXListBoxItemData.SetSelectedStyle;
begin
  //TXListBoxItem(ItemObject).StyleClass:= 'XListBoxItemSelectedStyle';  //does not work
  //TXListBoxItem(ItemObject).Label.StyleClass:= 'XListBoxItemSelectedStyle';  //does not work
 

TXListBoxItem(ItemObject).Label.Color:= clBlack;  //works
  TXListBoxItem(ItemObject).Label.Font.Color:= clWhite; //works
end;

 

It seems that the StyleClass will not happen instaneously.  Is there a method that has to be called after setting StyleClass to get it to refresh immediately? When I select an item, I do not see the Style change until I select another item, then the previous item I selected, changes

Download from Github

Thanx

Share this post


Link to post
Share on other sites

Found the problem in your CSS. Try this:

.XListBoxItemSelectedStyle{
 background-color: #000000;
 color: #FFFFFF
}

.XListBoxItemStyle{
 color: #000000;
 background-color: #FFFFFF

 

Share this post


Link to post
Share on other sites
23 minutes ago, jarto said:

Found the problem in your CSS. Try this:


.XListBoxItemSelectedStyle{
 background-color: #000000;
 color: #FFFFFF
}

.XListBoxItemStyle{
 color: #000000;
 background-color: #FFFFFF

 

hmmm, how'd i miss that?  thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×