|
Ah yes, a good point
If my jokes make me laugh, then I have already succeeded with 100% of my target audience
|
|
|
|
|
Hi all,
this error comes when i am using win32 dll in c# application.
An unhandled exception of type 'System.BadImageFormatException' occurred in Test.exe
Additional information: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
please help me for this.
thanks in advance.
|
|
|
|
|
32/64 bit mismatch!
you have to set the target cpu to x86, then it will work.
I cannot remember: What did I before google?
|
|
|
|
|
but both are build on same machine and platform.
|
|
|
|
|
if you are running a .net application, build for target "any cpu", the program will start as a 64 bit application - if the machine is running a 64 bit windows.
and if your win32.dll (doesn´t sound like an .net dll) is build for 32 bit (why do i think it is? maybe the 32 in win32.dll?, then it is not possible.
you have to build the .net app explicitly for x86 target. dot.
I cannot remember: What did I before google?
|
|
|
|
|
Hi
I am trying to set the BackColor of a specific cell (C2010 Enterprise), but have failed so far - can you help!
I have tried this:
DataGridView1[2, 3].Style.BackColor = Color.Red;
but that didnt work (doesnt appear to do anything)
Have you any other suggestions?
Cheers
|
|
|
|
|
Try setting the DefaultGridViewCellStyle - some code here[^].
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
How/Where are you determining which cell and trying to set it?
I usually do things like this to highlight a cell containing a value that is out-of-tolerance or such, i.e. like below 75 or whatever.
private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
DataGridViewRow R = dataGridView1.Rows[e.RowIndex];
R.Cells[6].Style.BackColor = Color.Red;
}
Or do it like in the MSDN link in the CellFormatting event, which may be better.
|
|
|
|
|
Thanks for replying!
I have just tried your example, and that was fine. I have now gone back to my original and that seems to be working as well?! I dont know what I was doing before, but all is OK now
Cheers
Mike
|
|
|
|
|
Hi,
I am currently doing a project in C#.net. I am using a datagridview for data entry purpose.
The first column is a drop down combox column. After selecting the value from the list, I press Enter key. The cursor is not moving to next cell. It is moving to the next row of the same column. How to make it to move to the next column of the same row. Please help me.
private void frmInward_Load(object sender, EventArgs e)
{
txtInwardNo.Text=ReturnInwardNo();
LoadGridcolumns();
LoadSuppliers();
}
private void LoadGridcolumns()
{
string SQL;
OleDbConnection obcon = new OleDbConnection();
SQL = "";
SQL = "select '' as ItemGroup,'' as Item,Qty,Amount from InwardDetails";
obcon.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/MsBakery.mdb";
obcon.Open();
OleDbDataAdapter obda = new OleDbDataAdapter(SQL, obcon);
DataSet ds = new DataSet();
obda.Fill(ds,"InwardDetails");
dgvInwardDet.DataSource = ds;
dgvInwardDet.DataMember = "InwardDetails";
dgvInwardDet.AutoResizeColumns();
}
private string ReturnInwardNo()
{
string InwardNo;
InwardNo = "";
OleDbConnection obcon = new OleDbConnection();
OleDbCommand obcmd = new OleDbCommand();
string SQL;
bool status;
status = false;
try
{
obcon.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/MsBakery.mdb";
obcon.Open();
SQL = "SELECT TOP 1 InwardNo FROM Inward ORDER BY InwardNo DESC";
obcmd.CommandText = SQL;
obcmd.Connection = obcon;
OleDbDataReader obdr = obcmd.ExecuteReader();
if (obdr.Read())
{
InwardNo = Convert.ToString(Convert.ToInt32(obdr["InwardNo"].ToString()) + 1);
}
else
{
return "1";
}
}
catch (OleDbException ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
status = true;
}
finally
{
obcon.Close();
if (!status)
{
obcon = null;
obcmd = null;
}
}
return InwardNo;
}
private void LoadSuppliers()
{
DataGridViewComboBoxColumn dgvcomcol = new DataGridViewComboBoxColumn ();
dgvcomcol.MaxDropDownItems = 5;
dgvcomcol.AutoComplete= true;
dgvcomcol.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
dgvcomcol.DisplayIndex = 0;
dgvcomcol.HeaderText = "Supplier";
PrepareSupplierCombo(dgvcomcol);
dgvInwardDet.Columns.Add(dgvcomcol);
dgvcomcol.Width = 100;
}
private void PrepareSupplierCombo(DataGridViewComboBoxColumn col)
{
OleDbConnection obcon = new OleDbConnection();
string SQL;
obcon.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/MsBakery.mdb";
obcon.Open();
SQL = "SELECT SupplierName as Supplier,SupplierID FROM Suppliers";
OleDbDataAdapter obda = new OleDbDataAdapter(SQL, obcon);
DataSet ds = new DataSet();
obda.Fill(ds, "Suppliers");
col.Items.Clear();
col.DataSource = ds.Tables[0];
col.DisplayMember = "Supplier";
col.ValueMember = "SupplierID";
}
private void dgvInwardDet_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
ComboBox com = e.Control as ComboBox;
com.AutoCompleteMode = AutoCompleteMode.Suggest;
com.AutoCompleteSource = AutoCompleteSource.ListItems;
com.FlatStyle = FlatStyle.Flat;
}
With Regards,
Arun V
|
|
|
|
|
Hello bugindia,
if I understand you hitting enter to move to the next cell in the same row, handle the KeyDown event of your datagrid class SystemKeys and force by moving the cursor to the right and subsequently has an example here.
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
SendKeys.Send("{Right}");
e.Handled = true;
}
}
Bye
|
|
|
|
|
What is better:
void AddSharpsAndFlats(StaffVisual staff, Clef clef)
{
int symbolCount = _context.GetSharpCount();
if (symbolCount > 0)
for (int i = 0; i < symbolCount; i++)
{
staff.AddVisual(new SharpVisual
{
Position = clef.SharpPostions[(int)MusicContext.SharpOrder[i]]
});
staff.AddVisual(PlaceHolderVisual.ThinPlaceholder);
}
else if (symbolCount < 0)
for (int i = 0; i < -symbolCount; i++)
{
staff.AddVisual(new FlatVisual
{
Position = clef.FlatPostions[(int)MusicContext.FlatOrder[i]]
});
staff.AddVisual(PlaceHolderVisual.ThinPlaceholder);
}
}
OR: move symbolCount < 0 inside a loop (and use abs(symbolCount))? Then I would have a single loop but I would also have n checks. Note: symbolCount is a value in range {-7,...,-1,0,1,...,7} .
EDIT: corrected typo
Thanks and
Greetings - Jacek
modified on Tuesday, July 5, 2011 7:50 AM
|
|
|
|
|
Your logic doesn't work here. You can't have i starting at zero and then being compared to symbolCount when symbolCount is less than zero. The loop won't run.
|
|
|
|
|
t'was a typo which came out while debugging a moment after I have posted this / forgot to correct. It's done now.
Greetings - Jacek
|
|
|
|
|
As these are mutually exclusive conditions, I think that having them as separate loops is a perfectly valid construct. As soon as you add the abs(symbolCount) condition in there, you are introducing something that requires thinking about by somebody reviewing your code. While this isn't, necessarily, a bad thing, consider that if this is a commercial project, then at some point, Nervous Nigel the spotty apprentice coder is going to try to do something with the code and end up breaking it because he doesn't understand it.
The KISS principal applies.
|
|
|
|
|
Nervous Nigel has just made its way into my weekly vocabulary. Describes people I often refer to perfectly. Thank you good sir.
|
|
|
|
|
You're welcome - I know several of them.
|
|
|
|
|
I dunno. Maybe squeeze the loops into a common method?
if (symbolCount > 0)
{
AddSymbols ( SharpFactory , clef.SharpPostions , staff , symbolCount ) ;
}
else if (symbolCount < 0)
{
AddSymbols ( FlatFactory , clef.FlatPostions , staff , symbolCount ) ;
}
Just a thought.
Otherwise, leave it the way it is.
|
|
|
|
|
The two loops set off my code style alarms. But having reviewed it, and worked out the domain here, it really is two separate operations, and there's not much there that is common enough to pull out. When it comes down to it you're duplicating four lines:
for(int i = 0; i < symbolCount; i++) {
staff.AddVisual(something);
staff.AddVisual(PlaceHolderVisual.ThinPlaceholder);
}
So I think I would leave it, but with a note (mental or explicit) to watch this space because if you add more key signature related stuff it could get messy and need refactoring.
Now you could take the duplication out like this:
void AddSharpsAndFlats(StaffVisual staff, Clef clef)
{
int symbolCount = _context.GetSharpCount();
if(symbolCount != 0){
var Positions = symbolCount > 0 ? clef.SharpPositions : clef.FlatPositions;
var Order = symbol.Count > 0 ? MusicContext.SharpOrder : MusicContext.FlatOrder;
VisualCreator creator = symbolCount > 0 ? (p => new SharpVisual(p)) : (p => new FlatVisual(p));
symbolCount = symbolCount > 0 ? symbolCount : -symbolCount;
for (int i = 0; i < symbolCount; i++)
{
staff.AddVisual(creator( {
Position = Positions[(int)Order[i]]
});
staff.AddVisual(PlaceHolderVisual.ThinPlaceholder);
}
}
}
... where
delegate VisualCreator(Position position);
(You could also have a VisualFactory that hides that selection away from you.)
I'm not convinced that for such a small duplication this is worthwhile.
|
|
|
|
|
Prompt to write a program to work with web camera to as I understand it to use OpenCV? Tell a escho library (preferably C #) to work with web camera and computer vision? and in what language it is better to write C # or C + + Open CV is a library of C + + swoop I know
|
|
|
|
|
Some good C# hits here[^].
The best things in life are not things.
|
|
|
|
|
Check out this article Motion Detection Algorithms[^]
It shows you how to integrate a webcam with motion detection.
It was the basis for this TeboCam[^]
One small tip - your question is very brief however computer vision is a hugely complex area - even Microsoft have a long way to go with the Kinect...
Continuous effort - not strength or intelligence - is the key to unlocking our potential.(Winston Churchill)
|
|
|
|
|
Hi everyBody;
I want to browse my string like this:
int k = 0;
char car = ' ';
string successZero = string.Empty;
char[] arr;
arr = chaine.ToCharArray(0, chaine.Length);
if (arr [0] != '0')
{
while (k < chaine.Length)
{
car = arr [k];
if (car == '0')
{
successZero += car;
car = ' ';
k ++;
}
else
break;
}
}
else
successZero = "";
return successZero;
but if I enter "001" the arr [0]= 48 '0' and NOT '0' only
I don't know it appears to me that 48 (I know it is the ASCII of 0)
but I want to discutate sur arr[0] == '0' or not
How to remidiate to that?
ty
|
|
|
|
|
I'm not sure what you are trying to do but your code does not seem to correspond to your description. You are looking for a zero in the arry (maybe), or trying to count them, but the line:
if (arr [0] != '0')
means that you never enter the search loop if the first character of your string is '0', as is the case you describe.
The best things in life are not things.
|
|
|
|
|
Hi,
yes that what I search arr [0] appears to me always != '0' even I enter chaine = "001" it appears to me arr [0] = 48 '0'
what can I do?
ty
|
|
|
|