Click here to Skip to main content
15,918,808 members
Home / Discussions / C#
   

C#

 
GeneralRe: i see why C# SHOULD have required to catch exceptions now Pin
Nicholas Cardi12-Sep-04 13:57
Nicholas Cardi12-Sep-04 13:57 
GeneralRe: i see why C# SHOULD have required to catch exceptions now Pin
Salil Khedkar13-Sep-04 1:26
Salil Khedkar13-Sep-04 1:26 
GeneralRe: i see why C# SHOULD have required to catch exceptions now Pin
Salil Khedkar13-Sep-04 1:29
Salil Khedkar13-Sep-04 1:29 
GeneralRe: i see why C# SHOULD have required to catch exceptions now Pin
bjoernen13-Sep-04 2:58
bjoernen13-Sep-04 2:58 
GeneralRe: i see why C# SHOULD have required to catch exceptions now Pin
elguaro12-Oct-04 14:36
elguaro12-Oct-04 14:36 
GeneralRe: i see why C# SHOULD have required to catch exceptions now Pin
bjoernen12-Oct-04 20:08
bjoernen12-Oct-04 20:08 
Generalkeypreview problem ( listview and buttons) Pin
BrownJacket12-Sep-04 10:19
BrownJacket12-Sep-04 10:19 
GeneralListView Problem Pin
Tomas Brennan12-Sep-04 8:50
Tomas Brennan12-Sep-04 8:50 
Can anyone help me out with this and tell me what I'm doing wrong?

1. I have a form with a ListView control which will hold items for me...
2. I have declared a private variable of type ListViewItem ie.
private ListViewItem lvi = null;
3. In the ListView's MouseDown Event Handler, I check if the right mouse button is pressed, and to popup a context menu to delete the selected item.
private void ListView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
try{
if (e.Button == MouseButtons.Right && this.ListView.Items.Count >= 1){
this.ListView.Focus();
this.lvi = this.ListView.GetItemAt(e.X, e.Y);
if (this.lvi != null) this.lvi.Selected = true;
this.cntxtMenu.Show(this.ListView, new System.Drawing.Point(e.X, e.Y);
} /* if (e.Button == .....) */
}/*end try */
catch{}
}
4. cntxtMenu contains a Caption 'Delete' and the menu-item is called cntxtMenuDelete.
5. In the cntxtMenuDelete Click Event I have the following
private void cntxtMenuDelete_Click(object sender, System.EventArgs e)
{
try{
this.ListView.Items.Remove(this.lvi); /* THIS LINE CRASHES! */
}/* end try */
catch{}
}

I have omitted the Exception code for brevity here, in the comment above where I've highlighted the line that causes a crash...the message I get from the Exception handler is, mind you, it doesn't even tell me what kind of exception is it - "Specified argument was out of the range of valid values. Parameter name '0' is not valid for 'displayIndex'." It even cut across the exception handler and therefore it did not catch the problem. I loaded this code into the CLR debugger and got it to trap all Exceptions and got a ArgumentOutOfRangeException - guess where, not in my code but in system.windows.dll....weird! the CLR debugger says it crashed when the Listview was making a call to get_item(int displayIndex) based on the stack dump from the debugger. ie a LVM_GETITEM message, something went funny there....I even derived the Listview and added a custom WndProc override to trap the LVM_GETITEM message and to ignore it....thinking that would solve it but no...Any ideas? Is this a bug?

Thanks in Advance,
Tom.
GeneralRe: ListView Problem Pin
VanesaAFESRG12-Sep-04 17:05
VanesaAFESRG12-Sep-04 17:05 
GeneralRe: ListView Problem Pin
Tomas Brennan13-Sep-04 2:07
Tomas Brennan13-Sep-04 2:07 
GeneralRe: ListView Problem Pin
VanesaAFESRG13-Sep-04 14:42
VanesaAFESRG13-Sep-04 14:42 
GeneralRe: ListView Problem Pin
Tomas Brennan17-Sep-04 5:56
Tomas Brennan17-Sep-04 5:56 
GeneralRe: ListView Problem Pin
SandeepN13-Sep-04 13:05
SandeepN13-Sep-04 13:05 
GeneralRe: ListView Problem Pin
Tomas Brennan17-Sep-04 6:00
Tomas Brennan17-Sep-04 6:00 
GeneralPerformance question Pin
BoxenBiene12-Sep-04 4:21
BoxenBiene12-Sep-04 4:21 
Generalswitch question Pin
BoxenBiene12-Sep-04 3:37
BoxenBiene12-Sep-04 3:37 
GeneralRe: switch question Pin
Dennis C. Dietrich12-Sep-04 4:02
Dennis C. Dietrich12-Sep-04 4:02 
GeneralRe: switch question Pin
BoxenBiene12-Sep-04 4:26
BoxenBiene12-Sep-04 4:26 
Generalembeding a NumericUpDown column in a datagrid Pin
BaraaSh12-Sep-04 3:30
BaraaSh12-Sep-04 3:30 
Generalnumericupdown column in datagrid Pin
BaraaSh12-Sep-04 3:18
BaraaSh12-Sep-04 3:18 
GeneralRe: numericupdown column in datagrid Pin
sreejith ss nair12-Sep-04 20:50
sreejith ss nair12-Sep-04 20:50 
GeneralC# send arraylist between forms Pin
Member 119488412-Sep-04 3:15
Member 119488412-Sep-04 3:15 
GeneralRe: C# send arraylist between forms Pin
Nick Parker12-Sep-04 4:35
protectorNick Parker12-Sep-04 4:35 
GeneralRe: C# send arraylist between forms Pin
Member 119488412-Sep-04 5:14
Member 119488412-Sep-04 5:14 
GeneralRe: C# send arraylist between forms Pin
Nick Parker12-Sep-04 6:18
protectorNick Parker12-Sep-04 6:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.