|
|
yes i did that and i can access the parallel port also but i donot know how to display the values of sensor on pc??
|
|
|
|
|
Then you need to look up the documentation for the device you are interfacing with to find out what it will send you over the parallel port and how you want to represent that.
|
|
|
|
|
Cha, as if.
A while back I got around to buying one of these[^] in hopes that I could use it to sample and store outdoor temperatures. But it doesn't seem accurate and it only provides the temperature of the board, which warms up while it has power.
So I need to devise a way to only give it power when I want to gather a sample.
|
|
|
|
|
Hello Everybody,
I am creating a class in which i want to create a property of Name (Readable and Writable).
Which Will be Unique every time if i will be create this class.
and it will be checking for previous existing Object of Class.
if i create a class like :
Classname clsname = new Classname();
Classname clsname1 = new Classname();
then Output is
clsname.Name = Class1
clsname.Name = Class2
Then pls help me to do this work.
Thanks
If you can think then I Can.
|
|
|
|
|
Should be quite simple
public class Classname
{
public Classname()
{
this.Name = Guid.NewGuid().ToString();
}
}
Will this do?
|
|
|
|
|
What about...
public static class ClassNames{
private static int _count = 0;
public static string GetNextName(){
return "Class" + (_count++);
}
}
public abstract NamedClass{
public string Name {get;set;}
public NamedClass(){
this.Name = ClassNames.GetNextName();
}
}
public class Classname : NamedClass{
public Classname(){
}
}
...or something along those lines
If my jokes make me laugh, then I have already succeeded with 100% of my target audience
|
|
|
|
|
I use something similar to this to assign IDs to clients in my socket library, and in some other projects. Do note though that this isn't thread safe and it's better to use Interlocked.Increment if you want to call the ID generator from different threads.
|
|
|
|
|
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.
|
|
|
|