Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 798
  • Last Modified:

DevExpress Bars 5 to 6 - BarByName is gone, BarByComponentName not functioning properly. Help?

I use the method to introduce new elements to the bar during run time, when I say BarByComponent name, I mean that I need to invoke the name of the bar into a variable so I can call it whenever I want it, however I suspect this is not the case.

Issue: Instead of introducing the new element, a blank space is introduced instead, when clicked upon it generates an access violation error.

Example of my code:

var
  BarX: TdxBar;
begin
BarX := mainBar.BarByComponentName('barMenuList');
...

Thank you.
0
John86a
Asked:
John86a
  • 5
  • 4
  • 3
3 Solutions
 
Ephraim WangoyaCommented:

Your question is not very clear
However yo need to test the validity of the BarX
Assuming MainBar is type TdxBarManager

var
  BarX: TdxBar;
begin
  BarX := MainBar.BarByComponentName('barMenuList');
  if Assigned(BarX) then
  begin
      //do your stuff  
0
 
John86aAuthor Commented:
I was using that correctly, but after studying mad except logins I found out the reason for the error..

exception class   : EAccessViolation
exception message : Access violation at address 0064BEA0 in module 'RF8.exe'. Read of address 000000A0.

Main ($9c8):
0064bea0 +00000 RF8.exe      dxBar              32483   +0 TdxBar.GetItemLinks
006497b5 +00005 RF8.exe      dxBar              32483   +0 TdxBar.GetControl

At this exact point inside dxBar.pas:

function TdxBarItemControl.GetItem: TdxBarItem
begin
 Result := GetItemByLink(FItemLink)
end;
0
 
jimyXCommented:
Would you test following code please and show what's the result:
var
  BarX : TdxBar;
  Found : Boolean;
  i : integer;
begin
  Found := False;
  for i := 0 to MainBar.Bars.Count-1 do
    begin
      if MainBar.Bars[i].Name = 'barMenuList' then
        begin
          Found := True;
          //BarX := MainBar.Bars[i];
          break;
        end;
    end;

  if Found then
    Showmessage('barMenuList found')
  else
    Showmessage('barMenuList not found')
end;

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jimyXCommented:
Just noticed something, doesn't "BarX" require to be created first before used?
Something like this:
var
  BarX: TdxBar;
begin
  BarX := TdxBar.Create(MainBar);
  BarX := MainBar.BarByComponentName('barMenuList');
  //...
  BarX.Free;
end;

Open in new window

0
 
Ephraim WangoyaCommented:
@jimmyX
What is that?
How can you create an object that you are searching for?
That is plain wrong.
0
 
John86aAuthor Commented:
That's not the origin of the error, this is:

try
 dxbarManager.LockUpdate := true;
 DeleteMenus;
 RecreateMenus(mainBar);
 Finally
 try
 dxBarManager.LockUpdate := False;
 Except
 end;
end;
0
 
jimyXCommented:
@ ewangoya
What to say man, over 12 hours looking at the screen, my brain is fried.
0
 
Ephraim WangoyaCommented:

@jimmyX
I know the feeling, happens to all of us one time or another
0
 
Ephraim WangoyaCommented:

What is the code in DeleteMenus.
Before destroying an item in your DeleteMenus procedure, change its visible property to false Control.Visible := False

try
 dxbarManager.LockUpdate := true;
  try
    try
      DeleteMenus;
      RecreateMenus(mainBar);
    except
      //why are you hiding the exception
    end;
 Finally
   dxBarManager.LockUpdate := False;
 end;

  //try updating the mainBar
  mainBar.Update;  //or refresh
end;
0
 
John86aAuthor Commented:
Update or refresh does not exist. Do you have msn? I have separated its and bits of the parts where debugger accused the error. I do not wish to post it here.
0
 
John86aAuthor Commented:
I'll accept your msn as a solution, and then we can go on from there.
0
 
John86aAuthor Commented:
Issue unresolved, going to be doing some debugging to get to the bottom of it. Might post another question later.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 5
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now