c#,winforms,excel,datagridview,exportRelated issues-Collection of common programming errors


  • Bruno Brant
    c# visual-studio
    Confusing title, confusing question, but I hope I can get your attention. To the point:I have a VS solution with three projects. Project1: A Native DLL interop wrapper, which imports Native.dll. Project2: A WinForms project that make calls to the wrapper contained by Project1. Project3: A MSTest project that make calls to the wrapper contained by Project1 Project2.I have included Native.dll in the Project1, and configured it to be copied to the output folder. This setup will result in the DllImp

  • Kara
    c# vmware vix
    I’m developing a C# application which loads a C++ dll which opens VMware Player using VIX APIs. If the C++ dll is loaded by a C++ application then the virtual machine is loaded without problems, while when it is loaded by the C# application the function VihHost_Connect fails returning error 3 VIX_E_INVALID_ARG. I can’t figure out why the SAME dll works when loaded by a C++ application, but doesn’t work when loaded by the C# app. Any hints? Here it’s the code of the C# application.static class N

  • Santhosh
    c# c++ datetime
    I have a C++ client talking to a C# server and I have custom serialization for user defined types.Now I need to pass a date and time structure from C++ to C#. Googling led to the following approach:Fill up the date/time in SYSTEMTIME structure (This is not the current system time. But rather it will be filled up by the program based on certain conditions) Convert SYSTEMTIME to FILETIME Convert FILETIME to __int64 (this gives a 64 bit value representing the number of 100 nanoseconds interval fro

  • Danzomida
    c# database-connection connection-string sqlanywhere sybase-iq
    I’m trying to create an SAConnection into a Sybase IQ database. I’m attempting to create the connection through a simple visual studio C# application.My code fails at: SAConnection connection = new SAConnection(connString);And pops up with a message box: SQL Anywhere ADO.NET DataProviderFailed to load native dll (C:\Users\<Username>\AppData\Local\Temp\{16AA8FB8-4A98-4757-B7A5-0FF22C0A6E33}_0\dbdata.dllLink to picture of messageboxThe code subsequently throws an exception: “The type initial

  • Xcelled194
    c# c++ winapi dll
    This a question arising from this thread: Native C++ use C# dll via proxy C++ managed dllIn a nutshell, I’m loading (my) C# extension into a native process via a DLL. The extension needs to show a form so that the user can control it. I’m using standard .NET forms, no 3rd party librarys or anything, and my form is not showing up. Worse yet, it hangs the target process. It’s not using any CPU, so I get the feeling its waiting for some function to return, but never does.Also of interest is that th

  • user75569
    c# c++ windows-mobile native
    I have a windows mobile solution which contains two projects. One written in C# and another in C++ (unmaneged code that compiles into a dll). The part written in C# invokes some C++ functions from dll to connect to a server.If I open my application and I connect to the server everything works ok. If I minimize it , or if I open another windows mobile application over my application and try again to connect to the server it fails with a native exception code. (Exception code: 0xc000001d.)Any ide

  • torrential coding
    c# visual-studio-2010 dllimport
    I have used DLL Export viewer to try and find the functions that are in this DLL, I have found a list of functions and here it is:public: int __thiscall CSTVdsDisk::GetPartitionCount(void);the question is within in C# I am not able to call the function using either: [DllImport(“Some.dll”, ExactSpelling = true,EntryPoint = “GetPartitionCount”,CallingConvention = CallingConvention.StdCall,SetLastError = true)]or:[DllImport(“Some.dll”, ExactSpelling = true,EntryPoint = “CSTVdsDisk::GetPartitionCoun

  • krishna555
    c# visual-c++ c++-cli
    i have written a c++/cli program which calls my native c++ function which has the struct pointers as parameter to it. so its like i wrote a wrapper for my native c++ using c++/cli so that i can expose it to c# wcf program(which acts a server to another c++ client). now when i compile my c++/cli program, i didn’t get any errors and it got compiled and the dll for this c++/cli is generated, but when look at output window i see some thing like this failed in linking(which didn’t effect the compilat

  • Seth
    c# c++ interop c++-cli
    I have a mixed mode dll with native dll dependencies.I am loading the mixed mode dll from a C# exe using Assembly.Load. However, the location of the mixed mode dll is not in the application bin directory, therefore it fails because it only looks for the native C++ dll’s in the bin and the folders in the PATH environment variable.I thought using the option /assemblylinkresource was suppose to stop this and force the native dll’s to be found in the alternate directory alongside the deployed mixed

  • user3220513
    c# c++ wcf
    I run a WCF-Service in IIS-Express 8.0 and use Visual Studio 2010. The service calls a C++/CLI Wrapper, which calls the native C++ dll. If I start the client (C# Application), I am able to debug client, service and wrapper. If I try to step from the wrapper into the native C++ – Code, I fail. But from the return code I can see, that the function in the native C++ dll was called. In Addition: The native C++ dll is delay loaded from a path, I configure in the service via Global.asax-File. I also

  • Preetygeek
    java c++ winforms jni
    So, i have visual studio consloe project that compile to .dll file. I’ve created simple windows form System::Windows::Forms::FormI’ve created a .java file:import java.io.Serializable;public class MyBean implements Serializable{/*** */static{System.loadLibrary(“MyBean”); }private static final long serialVersionUID = 1L;private static native String getDateCpp();public String getDate(){return getDateCpp();}}compiled it and generate a .h file by javah:/* DO NOT EDIT THIS FILE – it is machine genera

  • Stormenet
    c# winforms compact-framework formborderstyle
    On a WindowsCE platform (custom build) our C# gui uses regular forms to show an “popup menu”. We set the FormBorderstyle to None as we don’t want the form controls to be visible.Some clients reported “Gray boxes” after a while. After some testing here we could reproduce the problem quite fast. When we open 2 different menu’s (forms) constantly the platform shows us an native exception.ErrorA native exception has occurredin Tiger.CEHost.exe. Select Quit andthen restart this program, or selectDeta

  • Seth Spearman
    winforms user-controls listbox selection
    I have several winforms listbox controls I am hosting in a user control. The behavior I want in this user control is that I only want ONE of the listboxes to have a selected item at a time. So if I have an item in Listbox1 selected and I click an item in listbox2 listbox one should be automatically have all items deselected.I have tried to accomplish this with the following code:dim listBox as listboxFor Each listName As String In _listboxes.KeysIf listName <> listboxName Thenlistbox = m

  • JPReddy
    c# winforms proxy wcf
    I have a WCF service hosted on a server. A client application is accessing the service on a windows 7 machine. There are two users on Windows 7 machine. Windows application is a installed through Clickonce so separate instance will be there for two users. When userA accessing the service through Winforms application it works fine, but when userB on the same machine trying to access it throws following exception: Communication Exception: The remote server returned an unexpected response: (417) Ex

  • pierocampanelli
    .net winforms unit-testing design
    I have an accounting & payroll client/server application where there are several input form with complex data validation rules. I am finding an effective way to perform unit testing of user interface.For complex validation rules I mean: “Disable button X if I Insert a value in textfield Y” “Enable a combobox if I insert a value in a textfield” …… ……Most promising pattern i have found is suggested by M. Fowler (http://martinfowler.com/eaaDev/ModelViewPresenter.html).Have you any exper

  • Michael S. Scherotter
    .net winforms data-binding windows-7 combobox
    Let’s say we have the following code in a Windows application:ComboBox comboBox = new ComboBox() {AutoCompleteMode = AutoCompleteMode.SuggestAppend,AutoCompleteSource = AutoCompleteSource.ListItems,DataSource = new string[] { “”, “Ark”, “Boat”, “Bucket” },DropDownStyle = ComboBoxStyle.DropDownList }; this.Controls.Add(comboBox);TextBox textBox = new TextBox() {Left = comboBox.Right,Top = comboBox.Top,ReadOnly = true }; textBox.DataBindings.Add(“Text”, comboBox, “SelectedValue”); this.Controls.Ad

  • Soner Gönül
    c# .net winforms datetime type-conversion
    I need to store DateTime in int. So I tried below codesInt64 n = Int64.Parse(DateTime.Today.ToString(“dd-MM-yyyy”));orInt64 twoday_date=Convert.ToInt64(System.DateTime.Today.ToString(“dd-MM-yyyy”));but its showing error:Input string was not in a correct format.Where is the error?

  • Michael
    c# winforms office-interop outlook-addin excel-addins
    I have a custom excel add in, with a custom form that inherits from System.Windows.Forms.Form. When I call myForm.ShowDialog() Outlook opens (unintended). Everything else works as desired.The form’s code-behind is extraordinarily simple:using System.Windows.Forms; using Excel = Microsoft.Office.Interop.Excel;namespace VVVV.ExcelAddIns.ContainerManagement {public partial class SheetSelectionForm : Form{public SheetSelectionForm(List<Excel.Worksheet> worksheets){InitializeComponent();this.cm

  • BelottiGhilardi
    c# winforms media-player
    I have this code which checks if a song has ended, and if it has selects the next one. I have the song names in a ListBox, so when the next song gets selected the first function triggers. Can you explain me why it doesn’t play the song?private void Files_SelectedIndexChanged(object sender, EventArgs e) {player.URL = percorsi[Files.SelectedIndex]; }private void player_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent er) {if (er.newState == 8){Files.SetSelected((Files.Sel

  • sab669
    c# winforms devexpress
    I’ve got a MouseDown event on my GridView:private void gdcSVNDefaultView_MouseDown(object sender, MouseEventArgs e){var vw = (GridView)sender;var hitInfo = vw.CalcHitInfo(e.Location);DXMouseEventArgs.GetMouseArgs(e).Handled = SelectChildRows(hitInfo.RowHandle, vw);}private static bool SelectChildRows(int r, GridView view){if (!view.IsGroupRow(r) || !view.GetRowExpanded(r))return false;var childRowCount = view.GetChildRowCount(r);var first = view.GetChildRowHandle(r, 0);var last = (first + childR

  • Henri
    r excel date data.frame
    I import a .csv file (from Excel 2010) in R through the read.cv2() function. I get a dataframe. My column’s names should be dates, but I get something like X08.03.2013. I have several questions : How can I set those names as a Date format (idem for the line’s names) ? For columns, once I got the date format, how can I use condition (if) on these Dates ? I hope I have been clear enough. Thank you for your help.

  • Robin Day
    c# asp.net excel
    For part of a web application the user needs to import some data from a spreadsheet. Such as a list of names and email addresses. Currently we do this by asking the user to browse for and upload a CSV file.Unfortunately, this isn’t always possible as various corporate IT systems only allow users to access files from document management systems and they have no privileges to save these to a local drive or network share.The solution we have is to allow the user to cut and paste the entire sheet (C

  • horgh
    c# excel windows-services interop
    I’m developing a windows service, generating a report. This report has a template. This template is prepared in an excel file. This file is copied to the output folder. While developing I launched the service like a console application and had no problems accessing this file.Then I prepared a service installer. The service is installed under Local System account. So this excel template file is marked as content and copied to the installation directory together with the executable as well. But wh

  • Siddharth Rout
    excel excel-vba range cell target
    I run into this issue a fair amount and am curious if someone can tell me why or how I can write this a little cleaner.Below is my code and it does work.If Target.Row = rTime.Offset(0, 1).Row ThenIf Target.Column = rTime.Offset(0, 1).Column ThencboStatus.ActivateEnd If End IfHow come I can’t just write it like this?If Target = rTime.Offset(0, 1) ThencboStatus.Activate End IfIf target is already a range then why do I need to specify the individual row and individual column? That second code will

  • Doc Brown
    excel vba
    I have a report generator in Excel VBA, which works so far. It reads some input data and produces as a formatted Excel sheet as result. The last column of this sheet is filled with some kind of free text. Now, sometimes the free text does not fit into the last column, it is just too wide. Since the row height of all rows of this report is fixed, I cannot set range.WrapText=True for this column (to let the text stay visible, one would have to increase the row height). A manual (non-VBA) solution

  • user1787425
    excel vba filtering
    I am having a problem using a filtered range in VBA. If I use a macro to filter the range, then use another to call a Subtotal worksheet function to find a minimum values in the first column, I get the expected minimum for the filtered range; this is what I want. This is shown here:Sub TestFilterTrans()Call FilterTrans(“111Wall”) End SubSub TestMinDate()MsgBox MinTransDate() End SubSub FilterTrans(Inv As String)Range(“TransLabels”).SelectSelection.AutoFilterActiveSheet.Range(“Trans”).AutoFilter

  • dcaswell
    asp.net excel iis
    I have a web app which is working fine in IIS 6 ex:loading page, loading doc and excel file perfectly. recently I moved the same web app code ti windows server 2008 R2 IIS 7. Now it is not working correctly, it is browsing but it is not loading the Excel and doc files properly.Additonal Trouble Shooting InfoAdding to the above when i checked the event viewer i am getting below informationThe description for Event ID 0 from source Quotes cannot be found. Either the component that raises this eve

  • Jean-François Corbett
    excel vba excel-vba
    I’m trying to populate a dynamic array with data from a sheet. I get the “error 9 subscript out of range”. Why? Sub correct()Dim row As Integer, i As Long Dim constants() As Double ‘this declares the dynamic array row = 1 i = 0ReDim constans(0) ‘this resizes the array(rediminsion’s the array)Do Until ThisWorkbook.Sheets(“Deg 4”).Cells(row, 1).Value = “”constants(i) = ThisWorkbook.Sheets(“Deg 4”).Cells(row, 1).Valuei = i + 1 ‘increments array indexReDim Preserve constants(i) ‘resize the array 1 l

  • Filburt
    excel excel-vba renaming
    I know how to make marcos but during school he never taught me everything to do with them, mainly with the Dim. My questions is how to I make a marco that will rename all my sheets expect for the first four. Sub RenameSheet()Dim rs As WorksheetFor Each rs In Sheetsrs.Name = rs.Range(“D5”)Next rsEnd SubWorks for every sheet but I dont want to be renaming every sheet. My first four are Documentation, Summarry, RONATemplate, KaycanTemplate. Which I want to leave has is. I cant really just put thos

  • MemLeak
    java excel drop-down-menu apache-poi
    I’ve tried to solve following Problem with Apache Poi 3.8, 3.9 and 3.10.beta.1I use following example code to create a Dropdown:CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0, 0);DVConstraint dvConstraint = DVConstraint.createExplicitListConstraint(new String[] { “10”, “20”, “30” });DataValidation dataValidation = new HSSFDataValidation(addressList,dvConstraint);dataValidation.setSuppressDropDownArrow(false);mySheet.addValidationData(dataValidation);In mySheet, column 1 is u

  • Arnold4107176
    c# list datagridview virtual
    Previously I asked a question about my dataGridView’s performance due to it havign to display a large amount of rows that get added based on an incoming stream. Multiple solutions were given, one of them enabling virtual mode. MSDN has an article on the subject but it feels more complicated than what I need as it uses a database and an editable field. My DataGridView is only for displaying and the data I display is placed in a List.After I accepted an answer I received this link: http://www.code

  • kobaltz
    c# csv datagridview datasource
    I have the following code which pulls the data from a CSV file specified by the user. The CSV file is without any headers and has four columns of data. I’m trying to import this data into the dataGridView datasource, but get unexpected results. Each time, it takes the first row and makes it the header column. I tried inserting a row at the beginning (commented out text), but it will only add the row to the datasource, but not treat it as the header. I’m not too worried about having headers, but

  • Igby Largeman
    c# .net sql ado.net datagridview
    My DataGridView is bound to a database query result via a SqlDataReader, and when I test a cell value for null, I’m getting unexpected results.My code is something like this:SqlConnection con = new SqlConnection(“Data Source = .;Initial Catalog = SAHS;integrated security = true”); con.Open(); SqlCommand cmd3 = new SqlCommand(“select Status from vw_stdtfeedetail where Std= 6 and Div =’B’ and name=’bbkk’ and mnthname =’June'”, con); SqlDataReader dr = cmd3.ExecuteReader(); BindingSource bs = new

  • davioooh
    c# .net winforms validation datagridview
    I’m working with DataGridViews in a Windows Form project. I’d like to obtain something similar to what appens, in edit mode, in MS SQL Server Management Studio.I try to explain: I’ve some mandatory columns in my datagrid and I’d like a row is added to the grid only if the values in these columns are valid. If the value of a cell is not valid I’d like to warn the user with a message box and pressing ESC, the incorrect row should be resetted.I tried using CellValidating and RowValidating events, b

  • SteveZ
    vb.net datagridview listbox
    I am encountering what appears to be buggy behaviour by the DGV ListBox control. I’m wondering if there are some “properties” I need to set differently, or alternatively, whether someone has coded some work-arounds for these annoying traits of this control.Regular VB ListBox drop-down control: The first MouseClick on Control causes the dropdown to appear but the edit box remains as it was, either with data which was there originally, or empty if it was empty. If the user then clicks in the free

  • Leron
    winforms visual-studio-2010 datagridview
    I have a dataGridView with a few columns that I’ve arranged according to the order they must appear. However in Visual Studio 2010 in the design view I get this :But when I start the project i debug mode I see this :As yo can see the Delete column has moved. I don’t know why. I tried different scenarios like editing the grid myself and moving the Delete column somewhere else but with no effect. I use a dummy class to get this empty row of data if this somehow has impact on the behavior of this

  • Afnan Bashir
    c# winforms exception datagridview
    I have 1 MDI Parent form named as MainForm and 2 child forms WorkForm and UserOp.WorkForm has datagridview that displays the users and its datasource is BindingList.the BindingList is created from a List of type user and list is declared in parent and is accessed in this with refrence i.e if i make any change to this list eventually it changes the list at parent. here is code how it is done.MainForm mainForm;public WorkForm(MainForm main){InitializeComponent();this.mainForm = main; }similarly it

  • Robert Harvey
    c# linq-to-sql datagridview
    I want to be able to select the columns that are displayed in my DataGridView. I.e., I have a linq query that returns an IEnumerable but I don’t want to display all the properties of Policy – I want to allow the user to choose what to display. So I thought something like this might work to create a “narrower” object with only the columns I want.IEnumerable<Policy> policies = repository.GetPolicies(); var results = from p in policies select new {if (userPicked(“PropertyOne”)) PropertyOne =

  • Muhammad
    c# winforms datagridview formatting int
    I have a databound datagridview. In it I have a column that has NULL values and 1-12. How can I at runtime make the datagridview turn the 1 into January and display it in the cell? And the NULL into another pre-defined string?I tried looking at the cell format, changed it to custom, then put in “MMM” but it did not work and displayed “MMM” in the actual cell.Please help.EDIT: Its winforms c#4.0, the field is bound to Int field from an entity in EF. And no need for culture sensitive, english is f

  • John Saunders
    c# winforms linq linq-to-sql datagridview
    // From my formBindingSource bs = new BindingSource();private void fillStudentGrid() {bs.DataSource = Admin.GetStudents();dgViewStudents.DataSource = bs; }// From the Admin classpublic static List<Student> GetStudents(){DojoDBDataContext conn = new DojoDBDataContext();var query =(from s in conn.Studentsselect new Student{ID = s.ID,FirstName = s.FirstName,LastName = s.LastName,Belt = s.Belt}).ToList();return query; }I’m trying to fill a datagridview control in Winforms, and I only want a fe

  • Alexey Popkov
    plotting export output-formatting
    When I open a .docx file containing Mathematica graphs on a computer without Mathematica software installed, the graphs look corrupted. For example, PlotMarkers or FrameLabel looks differently. How can I keep these graphs looking as they were originally on a computer without Mathematica?

  • Reb.Cabin
    export import
    The Import command lets you do a HTTP GET from a URL, like this Import @ “http://merkosoncampus.com/wp-content/uploads/2011/05/higgs-boson.jpg”This sends an HTTP GET request to the server and presumably parses the response according to some rules for inferring the type of data, from the content or from the extension “.jpg” or whatever.Listening on the socket, we see something like thisGET http://merkosoncampus.com/wp-content/uploads/2011/05/higgs-boson.jpg HTTP/1.1 User-agent: Mathematica/8.0.4.

  • Henk Holterman
    c++ arrays file binary export
    I’ve been requested to find a way to export an array into a file in a binary way. So I searched for it on the internet and finally found something that works, but I really don’t understand why.It goes like this:fOut.write((char *)&_data, sizeof(_data));_data = array of integers…I have a couple of questions:is &_data the address to the first element of the array? whatever address it is, does that mean that we only save the address of the array? then how come I still can access the array

  • Diogo Pereira
    java eclipse jar export
    I’m trying to create a jar that will be used by multiple projects. This jar has code and includes some external libraries. Example: org.apache.http.HttpEntityThe problem is that after generating the jar of the “utility” project, and after including this new jar in other projects, I get an NoClassDefFoundError when I run the new project:Oops: NoClassDefFoundError An unexpected error occured caused by exception NoClassDefFoundError: org/apache/http/HttpEntityThe error is being lauched right after

  • user745595
    php bash variables export environment-variables
    I want to pass variables from bash to php in 1 script. I know it’s possible with 2 files and $argv in the php, but I would really like to put the script in 1 file. This is what i got now:#!/bin/bash echo “This is bash” export VAR=”blabla”/usr/bin/php << EOF <?phpecho getenv(“VAR”);?> EOFwhich works fine. But there is one problem: i can’t seem to store the getenv in a variable.#!/bin/bash echo “This is bash” export VAR=”blabla”/usr/bin/php << EOF <?php$var = getenv(“VAR”); ec

  • Aron Rotteveel
    php mysql excel export heredoc
    I need some help with this code from PHP Classes, that’s supposed to export MySQL to Excel.I’m getting the following error: Parse error: syntax error, unexpected T_SL in excelwriter.inc.php on line 100This is line 100:[Line100] function GetHeader() { $header = <<<EOH <html xmlns:o=”urn:schemas-microsoft-com:office:office” xmlns:x=”urn:schemas-microsoft-com:office:excel” xmlns=”http://www.w3.org/TR/REC-html40″> Help? Thank you!

  • user1418326
    java stored-procedures db2 export
    I am trying to use java to do a .ixf export from DB2. But keep getting: 00000021 SystemErr R com.ibm.db2.jcc.c.SqlException: An unexpected token “CALL SYSPROC.ADMIN_CMD(EXPORT TO “C://expor” was found following “BEGIN-OF-STATEMENT”. Expected tokens may include: “”. What did I do wrong?String lsSQL = “CALL SYSPROC.ADMIN_CMD(EXPORT TO \”C://export-test.ixf\” OF IXF MESSAGES ON SERVER SELECT * FROM EVENT)”; CallableStatement callStmt = caConnection.prepareCall(lsSQL); callStmt.execute();

  • Amyst
    excel export ssrs-reports
    I have a simple Reporting Services report, a simple table, created with BIDS 2005, with the report wizard.I run the report on a RS2008 R2 server as is and it renders perfectly.When I export to Excel, an extra row is appended just below the table. The row is hidden and has a heigth of 409.5. Where that row comes from ? How to get rid of it ?*nb – no extra row if run on a RS2005 server

  • bostaf
    mysql sql select csv export
    I want to format SQL results, then export to CSV (phpMyAdmin export).SQL statement:SELECT product.name, features.text FROM products as product, product_features as features WHERE features.product_id=products.id LIMIT 0,100Tables strucutre:Table products:———— id | name ———— 24 Baseball 25 RopeTable product_features:————————– id | text | product_id ————————– 45 Leather.. 24 46 Hardball 24 47 Nylon 25 48 Black 25Pro

  • halfer
    php mysql database excel export
    I keep getting the error “unexpected end of file in line 48″ although I only have 47 lines of code. I don’t know if there’s a problem in my code or if this is the right code to export my database query to CSV file.<html><head></head><body><form method=”POST” action=””>DATE FROM: <input type=”date” name=”datefrom”> TO: <input type=”date” name=”dateto”> <input type=”submit” value=”Extract excel file” name=”extract”></input></form><?php

Web site is in building