|
|
D'oh!
Sorry about that!
|
|
|
|
|
Hello,
I am trying to create columns in a datagridview which will have couple of textcolumns and one ComboColumn.
I am trying to add a class to the combo column. This class contains an ID column and a description column. When the user selects the item in combo column i want to extract the ID from the selected object.
But after populating the grid with my class, and selecting the dropdown, I am getting an error
"System.ArgumentException: DataGridViewComboCell value is not valid".
I have no code written in any of the events in the grid.
Any help is highly appreciated.
Here is my code snippet
datagridview1.ColumnCount = 2;
DataGridViewComboBoxCell dgvCell=new DataGridViewComboBoxCell();
//clsCombo is my class which has a constructor ID and Description
clsCombo objCombo = new clsCombo("1", "Male");
dgvCell.Items.Add(objCombo);
objCombo.ID = "2";
objCombo.Description = "Female";
dgvCell.Items.Add(objCombo);
objCombo.ID = "3";
objCombo.Description = "Other";
dgvCell.Items.Add(objCombo);
DataGridViewRow dgvRow = new DataGridViewRow();
dgvRow.Cells.Add(dgvCell);
datagridview1.Rows.Add(dgvRow);
Thanks
Siva
|
|
|
|
|
I've developed an application in C# that reads an Excel worksheet every second using Interop.Excel (Microsoft Excel 9.0 Object Library) (below is part of the code). This worksheet has many formulas and is also being fed by a DDE from another application.
It works fine for some hours but suddenly I receive the following error and Excel crashes:
Microsoft Excel - MySpread.xls: EXCEL.EXE - Application Error : The instruction at "0x301833e4" referenced memory at "0x12480010". The memory could not be "read".
I have the same spread being read by a VB6 application that uses Microsoft Excel 9.0 Object Library and it has never crashed, so I think the Interop.Excel is the problem here. Any hint?
Thanks.
public class Class1
{
public Class1()
{
}
private Excel.Application _excelApp = null;
private Excel.Workbook _myWorkbook = null;
private Excel.Worksheet _myWorksheet = null;
public void open()
{
_excelApp = new Excel.ApplicationClass();
// opens _myWorkbook and _myWorksheet
_myWorkbook= _excelApp.Workbooks.Open("MySpread.xls",
Type.Missing, Type.Missing,
Type.Missing, Type.Missing,
Type.Missing, Type.Missing,
Type.Missing, Type.Missing,
Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
_myWorksheet = (Excel.Worksheet)_myWorkbook.Sheets["Sheet1"];
}
public bool readSpread()
{
// gets data from A7 to AR60
Excel.Range oRng;
oRng = (Excel.Range)_myWorksheet.get_Range("A7", "AR60");
if (oRng==null) return false;
object[,] data = (object[,])oRng.Value2;
// extracts each value
string sProduct;
double dbPrice;
for(int r=1; r<=data.GetUpperBound(0); r++)
{
sProduct = Convert.ToString(data[r,1]).Trim();
dbPrice = Convert.ToDouble(data[r,4]);
//(...)
}
return true;
}
}
|
|
|
|
|
I have a tab control and on that control I want to have a submit button displayed regardless of the tab I choose - the submit button is always on top in the client area.
Please point me to documents / example of doing this.
Steve
|
|
|
|
|
Maybe I am missing what you are saying but can't you just put the submit button outside of the tab control?
Cheers
Disgyza
Programmer Analyst
|
|
|
|
|
I could do that. The situation is that I have multiple tab controls for different functions and the submit button is for the associated tab control.
Maybe a better idea is to have a submit button on each tabs client area because that is the information that is to be processed. Is there a way to make the same button appear, drawn, on the tabs client area when the tab is selected?
|
|
|
|
|
I don't think there is a way to draw the same control, but you can link the event handler of each submit button to one handler method.
sas9491 wrote: the submit button is for the associated tab control
Then why again does it need to be on top?
-- modified at 15:24 Friday 11th August, 2006
Cheers
Disgyza
Programmer Analyst
|
|
|
|
|
Couple of thoughts: 1 to provide a consitant interface, 2 so I had one area in code that would respond to all of the tabs responses, and 3 to cut down on the amount of overhead used for controls.
Linking the events sounds like a good alternate solution. Thanks
-SS-
|
|
|
|
|
Wrap the tab and the button in a panel or blank control. Then you can have one object with all of them.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
is it possible for me to allow my windows application that i have developed to be able to access a database on my server????
kenny
|
|
|
|
|
I don't mean to sound flipant, but why would this not be possible?
When you create a database connection string you specify the server to connect to, among other parameters.
only two letters away from being an asset
|
|
|
|
|
Mark Nischalke wrote: I don't mean to sound flipant, but why would this not be possible?
Because Access isn't a real database server.
Mark Nischalke wrote: When you create a database connection string you specify the server to connect to, among other parameters.
Not when you connect to an Access database. Then you specify the physical path to the database file.
---
b { font-weight: normal; }
|
|
|
|
|
keroed_edmond wrote: to access a database
Notice access A database, not an Access database
only two letters away from being an asset
|
|
|
|
|
Yes, you are probably right. I read "access database" in the subject line, and assumed (as there is no other reference to something that looks like a database name) that it was about the Access database.
---
b { font-weight: normal; }
|
|
|
|
|
keroed_edmond wrote: is it possible for me to allow my windows application that i have developed to be able to access a database on my server????
Yes, like Mark stated, use a connection string to tell the applications where the database is located. www.connectionstrings.com[^] has references to many common databases and their connection strings.
I'd like to help but I don't feel like Googling it for you.
|
|
|
|
|
Your mission, if you choose to accept it, is to go to the page that you linked to, look at the database connections for Access, and tell me where you specify the server that the database is located on.
---
b { font-weight: normal; }
|
|
|
|
|
\\Servername\Sharename\dbpath for the database path portion of the connection string. Works like a charm as long as the user has read/write access to the share.
|
|
|
|
|
wrote: look at the database connections for Access
Where are you going on about MS Access? The original poster wanted to know about accessing a database from the server. They might be using MSSQL, MySQL, Oracle, or Firebird. They didn't specify. The link I provided has connection strings that work plenty fine
I'd like to help but I don't feel like Googling it for you.
|
|
|
|
|
No, you can not use an Access database in that way.
I seem to have a faint memory of some sort of bridge/proxy that you can set up on the server to allow access to the database. Didn't sound very easy or very efficient...
If you have direct file access to the server, you might be able to set up permissions so that you can access the database directly. This might require that the computers belong to the same network domain. As this means that you access the entire database file over the network, and not only the data you request, it can be quite slow.
I think that your best bet would be to go for a limited database server, like MSDE or SQL Express, or a real database server, like MySQL or SQL Server.
---
b { font-weight: normal; }
|
|
|
|
|
I think you over-read the original post. He didn't say anything about using an Access database. He said "...to be able to access a database on my server."
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave Kreskowiak wrote: He didn't say anything about using an Access database. He said "...to be able to access a database on my server."
Thank you for pointing that out
I'd like to help but I don't feel like Googling it for you.
|
|
|
|
|
You didn't really specify what database engine you are using, and that impacts the answer. If it's Microsoft Access, you would need to place it on a shared drive on the server and use a UNC string for the database path (\\Servername\Sharename\path) part of the connection string (the user would also need read and write access to the share). For SQL server and other server base databases, you just need to specify the correct server in the connection string, and insure that the correct network client drivers were present on the client.
If you used ADO or ADO.Net and SQL server, you they will likely already be present. The connecting user will need to be a user known to the server if using windows authentication (either a domain member, or if a work group, have an account on the server with exactly the same username and password).
|
|
|
|
|
Sorry, responded to the wrong post - see my reply to Guffa below. He is incorrect, you can use Access on a server, with some reservations.
|
|
|
|
|
Rob Graham wrote: He is incorrect, you can use Access on a server, with some reservations.
Where am I incorrect? I explained how you could access the database file through the file system.
---
b { font-weight: normal; }
|
|
|
|