|
Hi Rajesh, Thanks for your answer.
I need a litle more help. I need to pass the string representation of the hex number of the upkey?
Iam trying this but doesnt work. may i not trying the on rigth way.
Thanks.
|
|
|
|
|
can u provide the code. what you tried.., so that i can help you on this...
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
Hi. here is the code porcion.
private void rtBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyValue == 38)//upkey
{
e.Handled = true; //for not executing on richtextbox directly the answer
//come from another function
serialPort1.Write("{0x26}");//This is the string representation of the
//hex keyup? I found more than one.
}
}
Thanks a lot for your time.
|
|
|
|
|
may be yoy are passing the wrong ASCII code,
0x26 for (Ctrl+Z),
Go through the below link , here all ASCII values are available
Ascii values[^]
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
i'm trying to get files with the a specified extension in a folder using a batch file , but when i give *.resource it doesn't get any file instead it shows "*.resource" with the path. ant idea how to get the file with the extension .resource .
thanx in advance.
|
|
|
|
|
Maybe I am extra thick today, but what does this have to do with C# ?
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
|
why you are using the batch file to get the file list..,
use the .net methods system.io.directory.getfiles to get the file list from directory..,
go throgh the below link
Get File list[^]
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
hi all,
i want a deskop notification from an xml file or from rss feed
with articles added when i be online
|
|
|
|
|
kjgiiy wrote: i want a deskop notification from an xml file or from rss feed
with articles added when i be online
And how do you plan to achieve this?
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi - I am trying to send a simple string over an established Bluetooth connection using serial port. The probelm here is I don't know if what I am doing is correct as neither application are throwing any exceptions. Here is the code for the remote application
private void btnConnect_Click(object sender, EventArgs e)
{
try
{
SerialPort inPort = new SerialPort("COM2", 9600);
inPort.Open();
string message = "Hello";
inPort.Write(message);
inPort.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
On the other end I have used an event handler:
private void DataReceviedHandler(object sender, SerialDataReceivedEventArgs e)
{
try
{
SerialPort inPort = new SerialPort("COM7", 9600);
inPort.Open();
string mess = inPort.ReadLine();
MessageBox.Show("This worked...");
inPort.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
When I click on the button on the external application nothing happens? Any ideas????
|
|
|
|
|
There could be dozens of things wrong, getting a serial communication up and running requires all of them being right. Here are some suggestions:
- start by checking your physical connection by the simplest means, e.g. one party is constantly sending text (say one line every second), the other party uses HyperTerminal to receive them. Now experiment with cables, connectors, port settings, until characters are coming in.
- only when that works is it worthwhile expanding the software.
One immediate hint: ReadLine waits for a line of text, i.e. some characters ending on SerialPort.NewLine (which defaults to CR or LF or both, I can't remember). Your Write isn't sending any of them, try WriteLine.
|
|
|
|
|
private void DataReceviedHandler(object sender, SerialDataReceivedEventArgs e)
{
try
{
SerialPort inPort = new SerialPort("COM7", 9600);
inPort.Open();
string mess = inPort.ReadLine();
MessageBox.Show("This worked...");
inPort.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
in the above handler comport should be open previously, the receive comport should be open before sending the data by the sender comport.,
And also problem may be the comport settings as said in the above answer.., check all the comport settings are correct before starting your serialport communication.
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
After alot of hair pulling and banging my head on the wall, finally figured out why by code isn't working. First of all, there are 4 serial ports available on my PC. The fact that I am trying to use the same serial port to test my Windows mobile application and send data over the same serial port explains why. So one would then suggest trying to use another port, well there is two problems with this; first active sync lunches and takes this spare serial port(have tried killing the process, this didn't help), Secondly also discovered that my Windows mobile device only supports on connection at a time so hence while I am testing it I can not open another port, which really sucks... So now I am diching using bluetooth all together and am using WiFi. I know what your thinking (won't I run into the same problems as with bluetooth), well with WiFi I am going to create a dummy application (desktop) that will sent strings, if this works I will then rebuild it as a Windows Mobile application, hopefully it should work...Thanks for the help everyone...
|
|
|
|
|
So in an effort to better learn C#, I'm taking a Java program used in one of my old classes and converting it. For the most part I've gotten things figured out, however the generics are throwing me for a loop as they aren't quite the same as Java.
I have a custom List class declared as follows:
public class List<A>
I also have a Function interface which is:
interface Function<A,B>
{
B f(A o);
}
Inside the List class I try the following and I get an error on the 'B' type, it's complaining that the namespace B could not be found. This sort of thing works fine in Java, I'm trying to figure out the comparable way to do it in C#.
public List<A> map (Function<A,B> fun)
|
|
|
|
|
That's because you used B as a generic type parameter but B does not exist.
If you change map to map<B> it should work (and with some luck you won't even need to make B explicit in invocations of map , if the compiler can figure out the type for you)
|
|
|
|
|
Thanks, that took care of it for me.
|
|
|
|
|
Say, I have a resource file Res.resx with strings predefined. Then I create a new form using designer. Is it possible to use the string resources from the designer view to assign the properties, like text, so the line in the designer file would look like:
this.Text = global::My.Namespace.Res.Localized_text; ?
|
|
|
|
|
I have seen most of sniffering application sniffs network traffic according to IP address or NIC cards. But I want to sniff at application level. Real example can be an Anti-virus Application. It can sniff and block requests at application level.
So how can I do something like that ? Any example or guidance ?
Or
Is there any way to find out which application sent a given request ?
|
|
|
|
|
Hi,
I am using c# and sql for this simple example and I have two related tables: Master, Details. The Primary Key in Master is MasterId and there is a Foreign Key in Details table to establish the relation. The columns of Master are bound to textbox while the Details table are bound to datagridview. MasterBindingSource and DetailBindingSource are generated automatically. My problem with this is that adding a new Master along with its Details, coz it errors with FK constraint violated. Actually, when I add a new Master, the MasterId value @ the textbox is -1, so the value that was recognized by the Details MasterId @ the datagridview is -1 likewise, so when the insertion is updated to the database, MasterId is automatically set by the db engine due to its identity property. However, this MasterId is not known to the dataset. So when the Details table is updated to the database, the error occurs(Sql Exception was unhandled). So I need help for this problem coz I tried everything but nothing happened.
Anyway, here is my simple code as shown:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace MasterDetail
{
public partial class Form1 : Form
{
//DsMasterDetail ds = new DsMasterDetail();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.masterTableAdapter.Fill(this.dsMasterDetail.Master);
this.detailTableAdapter.Fill(this.dsMasterDetail.Detail);
}
void Master_RowChanged(object sender, DataRowChangeEventArgs args)
{
}
private void masterBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
Validate();
masterBindingSource.EndEdit();
masterTableAdapter.Update(this.dsMasterDetail.Master);
dgvDetail.Refresh();
detailBindingSource.EndEdit();
detailTableAdapter.Update(this.dsMasterDetail.Detail);
}
private void dgvDetail_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
{
//e.Row.Cells[1].Value = bnPositionItem.Text;
}
}
}
Thanks in advance, your help will be greatly appreciated.
|
|
|
|
|
I think instead of using masterTableAdapter.Update(this.dsMasterDetail.Master);
you can use sql query to insert new data.
rahul
|
|
|
|
|
Hi Rahul,
Anyway, tnx for the reply. So I will redesign my code using a query instead of using MasterTableAdapter. I will send you feedback later if there's still a problem.
Thanks again.
|
|
|
|
|
Hi,
I think i found the best solution using this code below:
void save()
{
Validate();
// Disable constraints
ds.EnforceConstraints = false;
DsMasterDetail.MasterRow master = (DsMasterDetail.MasterRow)(((DataRowView)masterBindingSource.Current).Row);
DsMasterDetail.DetailRow detail = (DsMasterDetail.DetailRow)(((DataRowView)detailBindingSource.Current).Row);
masterBindingSource.EndEdit();
masterTableAdapter.Update(master);
detail.MasterId = master.MasterId;
detailBindingSource.EndEdit();
detailTableAdapter.Update(detail);
//Re-enable constraints
ds.EnforceConstraints = true;
}
This code solves my problem with Fk_Constraint. Actually it is working only for single data entry at details data table, but the only problem is that when adding a new Master at the textbox along with multiple details at the datagridview at the same time, coz it only fires up the last record of the datagrid and bypasses the corresponding rows. I need help for this problem.
Thanks.
Hardz
|
|
|
|
|
Redesign and don't use a Grid.
|
|
|
|
|
Hi,
Anyway, I am using a datagridview for data entry coz for every Master there's a corresponding multiple details, so the reason for using a datagridview is to enter many details.
Tnx for the reply..
|
|
|
|