HighTechTalks DotNet Forums  

The VJ# compiler crashes on compilation.

Dotnet VJSharp microsoft.public.dotnet.vjsharp


Discuss The VJ# compiler crashes on compilation. in the Dotnet VJSharp forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Jitesh Chourasia
 
Posts: n/a

Default The VJ# compiler crashes on compilation. - 05-14-2004 , 04:21 AM






While using System.Windows.Forms.ListView.Groups, the VJ# compiler crashes on compilation
Please suggest on how to get around the problem

Jitesh.

Reply With Quote
  #2  
Old   
Jitesh Chourasia
 
Posts: n/a

Default Re: The VJ# compiler crashes on compilation. - 05-17-2004 , 02:41 AM






Here is the exact code that crashes:

//<Snippet1
import System .*
import System.Collections .*
import System.Windows.Forms .*

public class ListViewGroupsExampl
extends For

private ListView myListView

private boolean isRunningXPOrLater = false

// Declare a Hashtable array in which to store the groups
private Hashtable groupTables[]

// Declare a variable to store the current grouping column
private int groupColumn = 0

public ListViewGroupsExample(

// Initialize myListView
myListView = new ListView()
myListView.set_Dock(DockStyle.Fill)
myListView.set_View(View.Details)
myListView.set_Sorting(SortOrder.Ascending)
// Create and initialize column headers for myListView
ColumnHeader columnHeader0 = new ColumnHeader()
columnHeader0.set_Text("Title")
columnHeader0.set_Width(-1)
ColumnHeader columnHeader1 = new ColumnHeader()
columnHeader1.set_Text("Author")
columnHeader1.set_Width(-1)
ColumnHeader columnHeader2 = new ColumnHeader()
columnHeader2.set_Text("Year")
columnHeader2.set_Width(-1)
// Add the column headers to myListView
myListView.get_Columns().AddRange(new ColumnHeader[] { columnHeader0, columnHeader1, columnHeader2 })
// Add a handler for the ColumnClick event
myListView.add_ColumnClick(new ColumnClickEventHandler(myListView_ColumnClick))
// Create items and add them to myListView
ListViewItem item0 = new ListViewItem(new String[] { "Programming Windows", "Petzold, Charles", "1998" })
ListViewItem item1 = new ListViewItem(new String[] { "Code: The Hidden Language of Computer Hardware and Software", "Petzold, Charles", "2000" })
ListViewItem item2 = new ListViewItem(new String[] { "Programming Windows with C#", "Petzold, Charles", "2001" })
ListViewItem item3 = new ListViewItem(new String[] { "Coding Techniques for Microsoft Visual Basic .NET", "Connell, John", "2001" })
ListViewItem item4 = new ListViewItem(new String[] { "C# for Java Developers", "Jones, Allen & Freeman, Adam", "2002" })
ListViewItem item5 = new ListViewItem(new String[] { "Microsoft .NET XML Web Services Step by Step", "Jones, Allen & Freeman, Adam", "2002" })
myListView.get_Items().AddRange(new ListViewItem[] { item0, item1, item2, item3, item4, item5 })
// Determine whether Windows XP or a later
// operating system is present
if (System.Environment.get_OSVersion().get_Version(). get_Major() > 5 || (System.Environment.get_OSVersion().get_Version(). get_Major() == 5 && System.Environment.get_OSVersion().get_Version().g et_Minor() >= 1)

isRunningXPOrLater = true


if (isRunningXPOrLater

// Create the groupsTable array and populate it with one
// hash table for each column
groupTables = new Hashtable[myListView.get_Columns().get_Count()]
for (int column = 0; column < myListView.get_Columns().get_Count(); column++

// Create a hash table containing all the groups
// needed for a single column
groupTables.set_Item(column, CreateGroupsTable(column))

// Start with the groups created for the Title column
SetGroups(0)

// Initialize the form
this.get_Controls().Add(myListView)
this.set_Size(new System.Drawing.Size(550, 330))
this.set_Text("ListView Groups Example")
} //ListViewGroupsExampl

/** @attribute STAThread(
* *
public static void main(String[] args

Application.Run(new ListViewGroupsExample())
} //Mai

// Groups the items using the groups created for the clicked
// column
private void myListView_ColumnClick(Object sender, ColumnClickEventArgs e

// Set the sort order to ascending when changin
// column groups; otherwise, reverse the sort order
if (myListView.get_Sorting() == SortOrder.Descending || (isRunningXPOrLater && e.get_Column() != groupColumn))
{
myListView.set_Sorting(SortOrder.Ascending);
}
else
{
myListView.set_Sorting(SortOrder.Descending);
}
groupColumn = e.get_Column();
// Set the groups to those created for the clicked column.
if (isRunningXPOrLater)
{
SetGroups(e.get_Column());
}
} //myListView_ColumnClick

//<Snippet2>
// Sets myListView to the groups created for the specified column.
private void SetGroups(int column)
{
// Remove the current groups.
myListView.get_Groups().Clear();
// Retrieve the hash table corresponding to the column.
Hashtable groups = ((Hashtable)(groupTables.get_Item(column)));
// Iterate through the items in myListView, assigning each
// one to the appropriate group.
for (int iCtr = 0; iCtr < myListView.get_Items().get_Count(); iCtr++)
{
ListViewItem item = myListView.get_Items().get_Item(iCtr);
// Retrieve the subitem text corresponding to the column.
String subItemText = item.get_SubItems().get_Item(column).get_Text();
// For the Title column, use only the first letter.
if (column == 0)
{
subItemText = subItemText.Substring(0, 1);
}
// Assign the item to the matching group.
item.set_Group((ListViewGroup)(groups.get_Item(sub ItemText)));
}
// Copy the groups for the column to an array.
ListViewGroup groupsArray[] = new ListViewGroup[groups.get_Count()];
groups.get_Values().CopyTo(groupsArray, 0);
// Sort the groups and add them to myListView.
Array.Sort(groupsArray, new ListViewGroupSorter(myListView.get_Sorting()));
myListView.get_Groups().AddRange(groupsArray);
} //SetGroups

//</Snippet2>
//<Snippet3>
// Creates a Hashtable object with one entry for each unique
// subitem value (or initial letter for the parent item)
// in the specified column.
private Hashtable CreateGroupsTable(int column)
{
// Create a Hashtable object.
Hashtable groups = new Hashtable();
for (; ; )
// Iterate through the items in myListView.
{
// Retrieve the text value for the column.
String subItemText = item.get_SubItems().get_Item(column).get_Text();
// Use the initial letter instead if it is the first column.
if (column == 0)
{
subItemText = subItemText.Substring(0, 1);
}
// If the groups table does not already contain a group
// for the subItemText value, add a new group using the
// subItemText value for the group header and Hashtable key.
if (!(groups.Contains(subItemText)))
{
groups.Add(subItemText, new ListViewGroup(subItemText, HorizontalAlignment.get_Left()));
}
}
// Return the Hashtable object.
return groups;
} //CreateGroupsTable

//</Snippet3>
// Sorts ListViewGroup objects by header value.
private class ListViewGroupSorter
implements IComparer
{
private SortOrder order;

// Stores the sort order.
public ListViewGroupSorter(SortOrder theOrder)
{
order = theOrder;
} //ListViewGroupSorter

// Compares the groups by header value, using the saved sort
// order to return the correct value.
public int Compare(Object x, Object y)
{
int result = String.Compare(((ListViewGroup)(x)).get_Header(), ((ListViewGroup)(y)).get_Header());
if (order == SortOrder.Ascending)
{
return result;
}
else
{
return -result;
}
} //Compare
} //ListViewGroupSorter
} //ListViewGroupsExample
//</Snippet1>

----- Lars-Inge Tønnessen wrote: -----


Please show us the code (or a small example) that is crashing.


Regards,
Lars-Inge Tønnessen




Reply With Quote
  #3  
Old   
AT
 
Posts: n/a

Default Re: The VJ# compiler crashes on compilation. - 09-06-2004 , 01:57 AM



Hi,

I tried the piece of code mentioned - I am just seeing some compile time
errors (MSDN documentation should help you here) and no crashes from the
compiler. Can you let us know if the crash is still reproing.

Thanks,
Diganta Roy
Microsoft Visual J# .NET Product Team

This posting is provided "AS IS" with no warranties, and confers no
rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

--------------------
Quote:
Reply-To: "Lars-Inge Tønnessen" <http://emailme.larsinge.com
From: "Lars-Inge Tønnessen" <http://emailme.larsinge.com
References: <46321FC2-99D1-43C4-802F-8FE68677A8CB (AT) microsoft (DOT) com
OYItXqbOEHA.628 (AT) TK2MSFTNGP11 (DOT) phx.gbl
<3EDF73B3-5044-411C-B362-4319DBF8F562 (AT) microsoft (DOT) com>
Quote:
Subject: Re: The VJ# compiler crashes on compilation.
Date: Mon, 17 May 2004 15:28:11 +0200
Lines: 16
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
Message-ID: <ueNYFTBPEHA.2256 (AT) TK2MSFTNGP10 (DOT) phx.gbl
Newsgroups: microsoft.public.dotnet.vjsharp
NNTP-Posting-Host: ans-065.vpn.uit.no 129.242.154.70
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP10
.phx.gbl
Quote:
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.vjsharp:6070
X-Tomcat-NG: microsoft.public.dotnet.vjsharp

You have a ListView and you want to call ".get_Groups()" on it ?

Here you will find all ListView members:
http://msdn.microsoft.com/library/de...-us/cpref/html
/frlrfsystemwindowsformslistviewmemberstopic.asp

http://msdn.microsoft.com/library/en...mWindowsFormsL
istViewClassTopic.asp

Are you sure you didn't mix the "myListView" variable or the ListView form
with anything else? Or maybe you are reading an example, and didn't include
all code?


Regards,
Lars-Inge Tønnessen





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.