COMBO CELLTYPE can't assign value without Farpoint Win blowing up when I use Itemdata

Posted by: ruotols on 8 September 2017, 1:31 pm EST

  • Posted 8 September 2017, 1:31 pm EST

    <P>I used to use this code on asp.net and now I am using vb.net windows.</P>
    <P>Cell type is combo.item = {"XXX","YYY","ZZZ"}</P>
    <P>.itemdata = {"100","200","300"}</P>
    <P>when the user logs in and the database has 200 stored I would like the combo box cell to default to 200 and display YYY.  I used to say cell.value = 200.  The code runs fine, but when the user clicks the horizonal scroll bar the grid throws an error and crashes </P>
    <P> Am I doing it wrong?  I tried Editor.setvalue, that did not work either.</P>
    <P>Thanks</P>
    <P>Steve</P>
    <P> </P>
    <P> </P>
    <P> </P>
  • Replied 8 September 2017, 1:31 pm EST

    <p>Steve -</p><p>You don't mention what version you are using.  I am not able to reproduce this so I would suggest making sure you have the latest maintenance release for the version you have. <br></p>
  • Replied 8 September 2017, 1:31 pm EST

    <P>I was using an older version - now I have 3.0.2009.2005 and can replicate it still in Visual Studio 2005</P>
    <P>Here is the code</P><FONT color=#0000ff size=2>
    <P>Dim</FONT><FONT size=2> oCellTypeDropDownSegments </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>New</FONT><FONT size=2> FarPoint.Win.Spread.CellType.ComboBoxCellType</FONT></P>
    <P><FONT size=2> <FONT color=#0000ff size=2>Dim</FONT><FONT size=2> cstrSegment </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>String</FONT><FONT size=2>()</P>
    <P></FONT><FONT color=#0000ff size=2>Dim</FONT><FONT size=2> cstrSegmentCode </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>String</FONT><FONT size=2>()</P></FONT></FONT><FONT size=2><FONT size=2>
    <P> </P><FONT size=2>
    <P></FONT><FONT color=#0000ff size=2>Dim</FONT><FONT size=2> strLookupSegment(dsSegments.Tables(</FONT><FONT color=#800000 size=2>"SEGMENTS"</FONT><FONT size=2>).Rows.Count) </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>String</P></FONT><FONT size=2>
    <P></FONT><FONT color=#0000ff size=2>Dim</FONT><FONT size=2> strLookupSegmentCode(dsSegments.Tables(</FONT><FONT color=#800000 size=2>"SEGMENTS"</FONT><FONT size=2>).Rows.Count) </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>String</P></FONT><FONT size=2>
    <P></FONT><FONT color=#0000ff size=2>With</FONT><FONT size=2> dsSegments.Tables(</FONT><FONT color=#800000 size=2>"SEGMENTS"</FONT><FONT size=2>)</P>
    <P></FONT><FONT color=#0000ff size=2>For</FONT><FONT size=2> intloopcount = 0 </FONT><FONT color=#0000ff size=2>To</FONT><FONT size=2> .Rows.Count - 1</P>
    <P>strLookupSegment(intloopcount) = _</P>
    <P>.Rows(intloopcount).Item(</FONT><FONT color=#800000 size=2>"SEGMENT_CODE"</FONT><FONT size=2>).ToString & </FONT><FONT color=#800000 size=2>" - "</FONT><FONT size=2> & _</P>
    <P>.Rows(intloopcount).Item(</FONT><FONT color=#800000 size=2>"SEGMENT_NAME"</FONT><FONT size=2>).ToString</P>
    <P>strLookupSegmentCode(intloopcount) = _</P>
    <P>.Rows(intloopcount).Item(</FONT><FONT color=#800000 size=2>"SEGMENT_CODE"</FONT><FONT size=2>).ToString</P>
    <P></FONT><FONT color=#0000ff size=2>Next</P></FONT><FONT size=2>
    <P></FONT><FONT color=#0000ff size=2>End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>With</P></FONT><FONT size=2>
    <P>cstrSegment = strLookupSegment</P>
    <P>cstrSegmentCode = strLookupSegmentCode</P></FONT>
    <P> </P>
    <P>oCellTypeDropDownSegments.Items = cstrSegment</P>
    <P>oCellTypeDropDownSegments.ItemData = cstrSegmentCode</FONT><FONT color=#0000ff size=2></P></FONT><FONT size=2>
    <P>oCellTypeDropDownSegments.AutoSearch = FarPoint.Win.AutoSearch.SingleCharacter</P>
    <P>.Cells(intRow, PRODUCT_COLS.SEGMENT_CODE_IN_BRAND).CellType = oCellTypeDropDownSegments</P>
    <P>This line cause the grid to blow up when I click on the horizontal scroll bar<FONT size=2></P><FONT size=2>
    <P>grid.ActiveSheet.Cells(intloopcount, PRODUCT_COLS.SEGMENT_CODE_IN_BRAND).Value = (dsProducts.Tables(</FONT><FONT color=#800000 size=2>"PRODUCTS"</FONT><FONT size=2>).Rows(intloopcount).Item(</FONT><FONT color=#800000 size=2>"SEGMENT_CODE_IN_BRAND"</FONT><FONT size=2>).ToString)</FONT></P>
    <P><FONT size=2></FONT> </P>
    <P><FONT size=2>Am I missing a setting when instantiating the combo cell above?</P></FONT></FONT>
    <P> </P>
    <P> </P></FONT></FONT>
  • Replied 8 September 2017, 1:31 pm EST

    I do not see this behavior in my own testing.  No exception is thrown when scrolling horizontally.  Do you have a small project you could attach showing this behavior?<br>
  • Replied 8 September 2017, 1:31 pm EST

    <P>Hello,</P>
    <P>What exception are you getting? Is the combobox showing the item until you scroll the Spread horizontally? One post you stated you are setting the Value property to 200, and then the code shows where you are passing in the 200 as a string "200". Have you set the EditorValue of the Combobox to ItemData. I think what Bob asked for in a small zipped project will be the most help to track down this issue.</P>
  • Replied 8 September 2017, 1:31 pm EST

    <P>I fixed the problem by adding this line of code</P>
    <P> </P>
    <P>.editorvalue = farpoint.win.spread.celltype.editorvalue.itemdata</P>
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels