DATA GRID and CTRL C

G

Guest

C# - Windows application.

Datagrid class... Data grid is populated with records. (see the code below)

Select one of the entire row from the grid (selected gfrom outside left
boundary).
The row gets highlighted...

Press CTRL C to mimic copy functionality.

boom!!! unhandled exception---


Please help my application is on production......!!!!!!!!!!!!!!!
NO do not suggest me to go to some thirdy party controls.....

Waiting positively for response TODAY



Following is the code just in case if at all really some one is going to read


Cursor.Current = Cursors.WaitCursor;
DataSet DSCycleHistory =new DataSet();
m_FiscalYear = cmbFiscalYear.Text;
sSql ="SELECT * FROM " + Global.TABLE_CYCLE_COUNT_HISTORY + " where
trim(to_char(execution_date,'YYYY')) = '"+m_FiscalYear + "' ORDER BY
COUNT_ID" ;
DSCycleHistory=OracleHelper.ExecuteDataset(Global.sConnStr,CommandType.Text,sSql);
//dgErrors.DataBindings =DSError;
//dgErrors.TableStyles[0].AlternatingBackColor = Color.Gray;
dgHistory.DataSource = null;
dgHistory.Enabled = false;
dgHistory.SetDataBinding(DSCycleHistory,"Table");
dgHistory.TableStyles[0].AlternatingBackColor = Color.LightGray;
dgHistory.Enabled = true;
dgHistory.PerformLayout();
dgHistory.Refresh();
 
P

Pete Davis

Where is the unhandled exception? What is the exception? That will usually
narrow it down to a specific line of code that's causing the problem.

Pete
 
G

Guest

Pete/All,

Here is the error trace

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Threading.ThreadStateException: The current thread must set to Single
Thread Apartment (STA) mode before OLE calls can be made. Ensure that your
Main function has STAThreadAttribute marked on it.
at System.Windows.Forms.Clipboard.SetDataObject(Object data, Boolean copy)
at System.Windows.Forms.DataGrid.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.TextBoxBase.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at
System.Windows.Forms.ThreadContext.System.Windows.Forms.UnsafeNativeMethods+IMsoComponent.FPreTranslateMessage(MSG& msg)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:///c:/winnt/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
Level Loading
Assembly Version: 1.0.1843.39871
Win32 Version: 1.0.1843.39871
CodeBase: file:///C:/Program%20Files/Level%20Loading/Level%20Loading.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Data.OracleClient
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.data.oracleclient/1.0.5000.0__b77a5c561934e089/system.data.oracleclient.dll
----------------------------------------
System.Data
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
----------------------------------------
System.Management
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.management/1.0.5000.0__b03f5f7f11d50a3a/system.management.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.enterpriseservices/1.0.5000.0__b03f5f7f11d50a3a/system.enterpriseservices.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.



Pete Davis said:
Where is the unhandled exception? What is the exception? That will usually
narrow it down to a specific line of code that's causing the problem.

Pete

Harshawardhan said:
C# - Windows application.

Datagrid class... Data grid is populated with records. (see the code below)

Select one of the entire row from the grid (selected gfrom outside left
boundary).
The row gets highlighted...

Press CTRL C to mimic copy functionality.

boom!!! unhandled exception---


Please help my application is on production......!!!!!!!!!!!!!!!
NO do not suggest me to go to some thirdy party controls.....

Waiting positively for response TODAY



Following is the code just in case if at all really some one is going to read


Cursor.Current = Cursors.WaitCursor;
DataSet DSCycleHistory =new DataSet();
m_FiscalYear = cmbFiscalYear.Text;
sSql ="SELECT * FROM " + Global.TABLE_CYCLE_COUNT_HISTORY + " where
trim(to_char(execution_date,'YYYY')) = '"+m_FiscalYear + "' ORDER BY
COUNT_ID" ;
DSCycleHistory=OracleHelper.ExecuteDataset(Global.sConnStr,CommandType.Text,
sSql);
//dgErrors.DataBindings =DSError;
//dgErrors.TableStyles[0].AlternatingBackColor = Color.Gray;
dgHistory.DataSource = null;
dgHistory.Enabled = false;
dgHistory.SetDataBinding(DSCycleHistory,"Table");
dgHistory.TableStyles[0].AlternatingBackColor = Color.LightGray;
dgHistory.Enabled = true;
dgHistory.PerformLayout();
dgHistory.Refresh();
 
U

Uri Dor

and what happens if you "Ensure that your Main function has
STAThreadAttribute marked on it" ?
Pete/All,

Here is the error trace

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Threading.ThreadStateException: The current thread must set to Single
Thread Apartment (STA) mode before OLE calls can be made. Ensure that your
Main function has STAThreadAttribute marked on it.
at System.Windows.Forms.Clipboard.SetDataObject(Object data, Boolean copy)
at System.Windows.Forms.DataGrid.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.TextBoxBase.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at
System.Windows.Forms.ThreadContext.System.Windows.Forms.UnsafeNativeMethods+IMsoComponent.FPreTranslateMessage(MSG& msg)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:///c:/winnt/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
Level Loading
Assembly Version: 1.0.1843.39871
Win32 Version: 1.0.1843.39871
CodeBase: file:///C:/Program%20Files/Level%20Loading/Level%20Loading.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Data.OracleClient
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.data.oracleclient/1.0.5000.0__b77a5c561934e089/system.data.oracleclient.dll
----------------------------------------
System.Data
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
----------------------------------------
System.Management
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.management/1.0.5000.0__b03f5f7f11d50a3a/system.management.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.enterpriseservices/1.0.5000.0__b03f5f7f11d50a3a/system.enterpriseservices.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.



:

Where is the unhandled exception? What is the exception? That will usually
narrow it down to a specific line of code that's causing the problem.

Pete

C# - Windows application.

Datagrid class... Data grid is populated with records. (see the code
below)

Select one of the entire row from the grid (selected gfrom outside left
boundary).
The row gets highlighted...

Press CTRL C to mimic copy functionality.

boom!!! unhandled exception---


Please help my application is on production......!!!!!!!!!!!!!!!
NO do not suggest me to go to some thirdy party controls.....

Waiting positively for response TODAY



Following is the code just in case if at all really some one is going to
read


Cursor.Current = Cursors.WaitCursor;
DataSet DSCycleHistory =new DataSet();
m_FiscalYear = cmbFiscalYear.Text;
sSql ="SELECT * FROM " + Global.TABLE_CYCLE_COUNT_HISTORY + " where
trim(to_char(execution_date,'YYYY')) = '"+m_FiscalYear + "' ORDER BY
COUNT_ID" ;

DSCycleHistory=OracleHelper.ExecuteDataset(Global.sConnStr,CommandType.Text,
sSql);

//dgErrors.DataBindings =DSError;
//dgErrors.TableStyles[0].AlternatingBackColor = Color.Gray;
dgHistory.DataSource = null;
dgHistory.Enabled = false;
dgHistory.SetDataBinding(DSCycleHistory,"Table");
dgHistory.TableStyles[0].AlternatingBackColor = Color.LightGray;
dgHistory.Enabled = true;
dgHistory.PerformLayout();
dgHistory.Refresh();
 
G

Guest

I encountered similar issue. To resolve the issue, you need to map all
columns in Dataset/table into Datagridtable style.

Thanks

Uri Dor said:
and what happens if you "Ensure that your Main function has
STAThreadAttribute marked on it" ?
Pete/All,

Here is the error trace

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Threading.ThreadStateException: The current thread must set to Single
Thread Apartment (STA) mode before OLE calls can be made. Ensure that your
Main function has STAThreadAttribute marked on it.
at System.Windows.Forms.Clipboard.SetDataObject(Object data, Boolean copy)
at System.Windows.Forms.DataGrid.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.TextBoxBase.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at
System.Windows.Forms.ThreadContext.System.Windows.Forms.UnsafeNativeMethods+IMsoComponent.FPreTranslateMessage(MSG& msg)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:///c:/winnt/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
Level Loading
Assembly Version: 1.0.1843.39871
Win32 Version: 1.0.1843.39871
CodeBase: file:///C:/Program%20Files/Level%20Loading/Level%20Loading.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Data.OracleClient
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.data.oracleclient/1.0.5000.0__b77a5c561934e089/system.data.oracleclient.dll
----------------------------------------
System.Data
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
----------------------------------------
System.Management
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.management/1.0.5000.0__b03f5f7f11d50a3a/system.management.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.enterpriseservices/1.0.5000.0__b03f5f7f11d50a3a/system.enterpriseservices.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.



:

Where is the unhandled exception? What is the exception? That will usually
narrow it down to a specific line of code that's causing the problem.

Pete


C# - Windows application.

Datagrid class... Data grid is populated with records. (see the code

below)

Select one of the entire row from the grid (selected gfrom outside left
boundary).
The row gets highlighted...

Press CTRL C to mimic copy functionality.

boom!!! unhandled exception---


Please help my application is on production......!!!!!!!!!!!!!!!
NO do not suggest me to go to some thirdy party controls.....

Waiting positively for response TODAY



Following is the code just in case if at all really some one is going to

read


Cursor.Current = Cursors.WaitCursor;
DataSet DSCycleHistory =new DataSet();
m_FiscalYear = cmbFiscalYear.Text;
sSql ="SELECT * FROM " + Global.TABLE_CYCLE_COUNT_HISTORY + " where
trim(to_char(execution_date,'YYYY')) = '"+m_FiscalYear + "' ORDER BY
COUNT_ID" ;


DSCycleHistory=OracleHelper.ExecuteDataset(Global.sConnStr,CommandType.Text,
sSql);

//dgErrors.DataBindings =DSError;
//dgErrors.TableStyles[0].AlternatingBackColor = Color.Gray;
dgHistory.DataSource = null;
dgHistory.Enabled = false;
dgHistory.SetDataBinding(DSCycleHistory,"Table");
dgHistory.TableStyles[0].AlternatingBackColor = Color.LightGray;
dgHistory.Enabled = true;
dgHistory.PerformLayout();
dgHistory.Refresh();
 
Top