Jump to content


Photo

Problem with ItemValue in NxComboBoxItem


  • Please log in to reply
11 replies to this topic

#1 Vladimir

Vladimir
  • Members
  • 5 posts
  • Gender:Male
  • Location:Russia

Posted 21 May 2009 - 09:27 AM

Sorry for my english, I'm from Russia rolleyes.gif

I try to execute the procedure:
CODE
void __fastcall TAdmining::NxComboBoxItem1CloseUp(TNxPropertyItem *Sender)
{
String s = ((TNxComboBoxItem*)NxInsp->Items->Item[1])->ItemValue;
ShowMessage("((TNxComboBoxItem*)NxInsp->Items->Item[1])->ItemValue="+s);
}

The result is a string starting from the second character. For example, it was selected "qwerty", the result will be "werty"
I think that does not properly function: TNxComboBoxItem.GetValueFromIndex (), may be I am wrong ...

Help me, please!

P.S.:
Properties for TNextInspector:
CODE
object NxInsp: TNextInspector
Left = 0
Top = 0
Width = 321
Height = 491
Align = alClient
Style = psOffice2007
TabOrder = 0
object NxTextItem1: TNxTextItem
Caption = 'TextItem'
Color = clWindow
ReadOnly = True
ParentIndex = -1
object NxComboBoxItem1: TNxComboBoxItem
Color = clWindow
OnCloseUp = NxComboBoxItem1CloseUp
Lines.Strings = (
'qwerty'
'asdfgh'
'zxcvbn')
ParentIndex = 0
end
end
end


#2 Vladimir

Vladimir
  • Members
  • 5 posts
  • Gender:Male
  • Location:Russia

Posted 21 May 2009 - 09:33 AM

Sorry for the repeat topic, I accidentally. wink.gif

#3 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 21 May 2009 - 05:58 PM

Hello Vladimir,

I have spot this bug. I will solve it in next couple of hours.

Kind regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 21 May 2009 - 06:07 PM

Hello Vladimir,

Open file NxPropertyItemClasses.pas. Find next procedure:

CODE
function TNxComboBoxItem.GetValueFromIndex(const Index: Integer): string;
begin
  if Index >= 0 then
    Result := Copy(FLines[Index], Length(FLines.Names[Index]) + 2, MaxInt) else
    Result := '';
end;


change it into:

CODE
function TNxComboBoxItem.GetValueFromIndex(const Index: Integer): string;
begin
  if Index >= 0 then
    Result := Copy(FLines[Index], Length(FLines.Names[Index]) + 1, MaxInt) else
    Result := '';
end;


(change + 2 into + 1). Then rebuild NextInspectorRun package.

Please tell me how its work. Thank you.

Kind regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#5 Vladimir

Vladimir
  • Members
  • 5 posts
  • Gender:Male
  • Location:Russia

Posted 21 May 2009 - 06:23 PM

Hello Boki!

Thank you for such a quick reply, I can check up only tomorrow.
Your software is the best! cool.gif

Best regards

#6 Vladimir

Vladimir
  • Members
  • 5 posts
  • Gender:Male
  • Location:Russia

Posted 22 May 2009 - 06:11 AM

Hello Boki!

Thank you very very much! Everything works fine! rolleyes.gif

Best regards

#7 CSE

CSE
  • Members
  • 54 posts
  • Location:Germany

Posted 12 November 2009 - 07:23 PM

Hello Boki,

I'm not sure, if Vladimir used the right settings and stringformat for using ItemValue property. But with your last change now there is a real bug in GetValueFromIndex function.
I have a TNxComboBoxItem with DisplayMode = dmValueList, Style = cbDropDownList and format of Lines content is "name=value". When I now set ItemIndex to a value > 0 the ComboBox shows "=value" instead of "value"! I also get this as a result of ItemValue property.
By the way, why are you copying the result in GetValueFromIndex function by yourself, there is a StringList function (ValueFromIndex) which does exactly the same? unsure.gif
Best regards,
Thomas

#8 Qwazerty

Qwazerty
  • Members
  • 73 posts
  • Gender:Male
  • Location:France

Posted 28 February 2016 - 01:25 AM

Hi Boki

 

Sorry to up this old post but... this bug is always here.

 

The actual version use this code

Result := Copy(FLines[Index], Length(FLines.Names[Index]) + 2, MaxInt) else

So ItemValue give an incomplet text.

 

Have you an other clean solution to get the previous selected text in OnSelect procedure ?

 

Thx



#9 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 28 February 2016 - 03:13 PM

Hi,

Please again try to change it 1. I am not sure why is not changed.

Can you please tell me the line of this code. Most probably I have miss to update it :(
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#10 Qwazerty

Qwazerty
  • Members
  • 73 posts
  • Gender:Male
  • Location:France

Posted 29 February 2016 - 03:01 PM

Hello

 

In NxClasses :

function ValueFromIndex(Strings: TNxStrings; Index: Integer): TString;
begin
  if Index >= 0 then
    Result := Copy(Strings[Index], Length(Strings.Names[Index]) + 1, MaxInt) else
    Result := '';
end;

Yes with +1 it's working fine but it seems that it pose problem with GetValueFromIndex (please see the message N°7 off this post).

 

But I though that ItemValue give the ol value off ListItem, I explaine what I need:

 

Imagine a ComboBoxItem (in an inspector) with lines = Word1, Word2, Word3
Word3 is selected
I'm selecting Word1 in the liste, OnSelect is fired : Is there a ComboboxItem's property who give the old value before this select (so Word3) ? Or I need to use a variable to memorise it ?

 

Have a nice day

Qwaz



#11 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 29 February 2016 - 09:25 PM

Hi Qwaz,

I am definitely not sure what's happening with this methods anymore :( I think that I will use standard TStrings.ValueFromIndex from now on.

I think that you will need to remember old value. Maybe I can add OnBeforeSelect event in both v5 and v6 for such situations. Or, even better OnSelectQuery where you can set var accept, inspect current, new value etc.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#12 Qwazerty

Qwazerty
  • Members
  • 73 posts
  • Gender:Male
  • Location:France

Posted 02 March 2016 - 04:47 PM

Or, even better OnSelectQuery where you can set var accept, inspect current, new value etc.

 

Hi Boki

 

Yes, it would be a good idear.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users