Home - Forums-General - Presale and licensing questions - Evaluation Progress

Presale and licensing questions

Evaluation Progress
Link Posted: 17-Jan-2007 20:57
As you can probably tell from my other posts on the forum, my evaluation isn't going very well. I've spent a fair amount of time trying to get the Flygrid to do what I want, and I spent another couple of hours today trying to adapt the object databinding code in your example application without success.

I am sure this is due to my inexperience with grid views and databinding and not the Flygrid, and I want to ask for explicit instruction on how to get what I need to achieve.

I have an application that uses an MS ListView control, and I want to change to a flexible tree view control that is fast -as your Flygrid seems to be. Here is an example of what I want it to look like:





Where Lexicon is a string, Level int, Frequency int.

The data type is:


class Word

String^ MemberWord
String^ Headword  
int Level
int Frequency
pointer to list view item


Each time I add a Word, I want it under the associated Headword. If the Headword is not yet in the tree, it should be created. If a Word is removed and there are no more under its Headword, then the Headword should be removed. I need to be able to reflect changes in Frequency as well.


How can I do this with a Flygrid?
Link Posted: 18-Jan-2007 05:04
Sorry that code in c#, but this code provides easy to understand to c++ programmers (I've no tested this code, but code well commented, hope this code will help you):
[c#]
private NodeBase AddWord(FlyGrid flyGrid, Word word)
{
  //search for node associated with headword
  NodeBase node = SearchHeadWord(flyGrid.Rows.Items, word);
  //if node not found - create and add node with headword
  if (node == null)
    node = AddHeadWord(flyGrid.Rows.Items, word);
  //add word to the headword node
  return AddWord(node, word);  
}

private NodeBase SearchHeadWord(NodeCollection nodes, Word word)
{
  for(int i=0; i < nodes.Count; i++)
  {
    NodeBase node = nodes[i];//get node
    //try to extract HeadWord instance from node.Value
    HeadWord hword = node.Value as HeadWord;
    //if associated value is Headword - compare with word.Headword
    if (hword == word.Headword)
      return node;
    //you can scan node's children. if it is necessary
    if (node.HasChildren and node.Items != null)
    {
      node = SearchHeadWord(node.Items, word);
      if (node != null) return node;
    }
  }
  return null;
}
private NodeBase AddHeadWord(NodeCollection nodes, Word word)
{
  //create node
  Node node = new Node(word.HeadWord);
  //add node to the nodes collection
  nodes.Add(node);
  //return created node
   return node;
}
private NodeBase AddWord(NodeBase node, Word word)
{
  //create node
  Node node = new Node(word);
  //add node to the nodes collection
  node.Items.Add(node);
  return node;
}
Link Posted: 18-Jan-2007 07:13
Thank you, I will try it. My only reservation is that the search method might defeat the purpose of a faster control.
Link Posted: 18-Jan-2007 07:27
You can increse search speed if you'll use Hashtable and register in the Hashtable all created with Headword nodes:
[c#]
private static Hashtable headwords = new Hashtable();
private void RegisterHeadword(Headword hword, NodeBase node)
{
  headwords[hword] = node;  
}
private NodeBase GetNode(Headword hword)
{
  return headwords[hword] as NodeBase;
}


or specify NodeBase in Headword when NodeBase is created
[c#]
private void RegisterHeadword(Headword hword, NodeBase node)
{
  hword.Node = node;
}

private NodeBase GetNode(Headword hword)
{
  return hword.Node;
}
Link Posted: 21-Jan-2007 15:46
Thanks for your great support. Please find my order when you get to work on Monday.
Link Posted: 22-Jan-2007 04:16
Thanks for the order - please check your mailbox for the registration info and downloading instructions.