|
There's hundreds of examples starting right here on cp and on google. Good luck.
|
|
|
|
|
most barcode scanners i have used emulate keyboard input...
|
|
|
|
|
Hi,
Please refer to the below mentioned articles:
http://www.codeproject.com/KB/graphics/barcodeimaging2.aspx
Hope this helps.
Vinay
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
I've uploaded my program through box.net, and i've sent it to two people, and they both say that it says "an error occured, and the program needs to close".
i've been giving it to them through this link: here.
is it working for you guys? i've told them to download this too, but they're still saying it's not working... what could be going on?
|
|
|
|
|
I assume they don't have the .NET framework installed.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
does it work on yours? and i've included in my question that i asked them to install the framework, and it gives the same message
I wish I could drive...
|
|
|
|
|
I didn't see a link, nor am I going to download and run a random program from the internet. Add some error logging code, and include a log at the top level, so that if no log is written, the program has not run at all ( so, no .NET, or wrong version of .NET )
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
sorry, somehow the post sent before i added the link. i went back and added it. thanks for the logging tip, i'll try that. but man... i don't remember the people on these forms being so rude
I wish I could drive...
|
|
|
|
|
I'm not being rude, I'm being practical. I'm sure your code is not malicious, but it's not smart of me to bank on it. I am still trying to help you.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
i know, it just came off to me that way when i first read it. thanks for the help!
|
|
|
|
|
I'm coming from the VFP environment and I'm learning C# on the fly. In FoxPro we have a property setting on text and combo boxes that allow for 'SELECT UPON ENTRY' which causes the object's foreground and background colors to change when the object receives focus. Also, when the user presses any key other than a tab or enter key the object is cleared and it receives the first keystroke and they can continue to fill in the text portion of the object. If they press tab, enter, or complete the maximum number of chars for the field the object loses focus and the color reverts back to what it was before it got focus.
How can I do this in C#?
Many thanks!
Jim White
|
|
|
|
|
The events Enter and Leave are for when the control gains/loses focus. So using those you could change the colours of your boxes.
You can use the event KeyDown to see what key the user has pressed before it's actuall passed to the text box so you can hadle your tab/enter keys there.
As for clearing the contents on the first key press, you'll just have to use a bool to check if its the first key press or not.
bool first = false;
OnEnter()
{
first = true;
}
.
OnLeave()
{
}
.
KeyDown(KeyEventArgs e)
{
if(key is tab OR key is enter) {
e.Handled = true;
MyForm.Focus();
}
.
if(first)
.
first = false;
}
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Is SuppressKeyPress property available in c# ?
i want to prevent user from entering any digits into a text field (anything other than digits are allowed)
so i gave the following code
void form1_KeyPress(object sender, KeyPressEventArgs e)
{
.
if (char.IsDigit(e.KeyChar ))
{
--i want to prevent user from entering any digit--
}
}
in VB there is a propery called SuppressKeyPress in KeyEventArgs. but its not there in C# . is there any other equivalent for SuppressKeyPress in C# ?
|
|
|
|
|
e.Handled = char.IsDigit(e.KeyChar )
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
thanks a lot..
i have one more doubt.
i need a textbox where the user can enter only
Alphabets (A-Z and a-z)
Space
and also allow them to use backspace and delete keys.
this is the code i tried
if (!((e.KeyChar >= 'A' && (e.KeyChar <= 'Z') || ((e.KeyChar >= 'a') && (e.KeyChar <= 'z')))))
{
e.Handled = true;
}
if (char.IsSeparator(e.KeyChar))
{
e.Handled = false;
}
but the above code wont allows the user to use backspace
plz help me to set e.handled = false when the key pressed by the user is a backspace so that he can erase the last character entered
|
|
|
|
|
This worked for me
int keycode = e.KeyChar;
if (!((e.KeyChar >= 'A' && e.KeyChar <= 'Z') || (e.KeyChar >= 'a' && e.KeyChar <= 'z') || keycode == 8 || keycode == 32)) {
e.Handled = true;
}
|
|
|
|
|
hey Navaneeth...
thanks a lot..
i solved my problem like this
if (!((e.KeyChar >= 'A' && (e.KeyChar <= 'Z') || ((e.KeyChar >= 'a') && (e.KeyChar <= 'z')))))
{
e.Handled = true;
}
if ((char.IsWhiteSpace(e.KeyChar)) || (e.KeyChar == (char)ConsoleKey.Backspace))
{
e.Handled = false;
}
but your solution is the smarter way to handle it..
I am new to codeproject.com and people like you will make this a better place for people like me to find solutions to their problems!!!
cheers!!
Arun
|
|
|
|
|
Hi,
two comments:
1. it is KeyEventArgs (as given by KeyDown and KeyUp) that holds a SuppressKeyPress property
2. all .NET classes are identical in C# and VB.NET, they are language-agnostic.
|
|
|
|
|
I am doing this in VC# and the object of KeyEventArgs didnt show the SuppressKeyPress.
instead the keyhit can be handled by
kKeyEventArgs e
e.Handled = true;
thnanks to Greeg !!
|
|
|
|
|
I have a user control that has 2 nested datalists. The second datalist requieres arguments from the first one to display the data. The main one shows the Product Categories and the second one shows the products for the selected category. When the user selects an item from the first I am calling "DataList_ItemCommand" which sets a session variable and then programatically binds the data for the second datalist. SOMETIMES (Mostly when the results are big or if I click to fast) I get an error on Internet Explorer which forces me to refresh the screen to see the data... Any ideas on what could be happening? Solutions?? Thanks Guys!
public void DataList_ItemCommand(Object sender, DataListCommandEventArgs e)
{
decimal nCpPk = (decimal)CategoryList.DataKeys[e.Item.ItemIndex];
Session["CategoryId"] = nCpPk;
BindData();
}
public void BindData()
{
//Dataset
DataSet DS = new DataSet();
//Create a connection to the SQL Server.
string strConnectionString = ConfigurationManager.ConnectionStrings["EckeMasterConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(strConnectionString);
//Session Variables
decimal tmpCategoryId = (decimal)Session["CategoryId"];
decimal tmpMainCateg = (decimal)Session["MainCateg"];
string tmpShipWeek = (string)Session["ShipWeek"];
int tmpAvailableOnly = (int)Session["AvailableOnly"];
string tmpProdForm = (string)Session["ProdForm"];
//Create a DataAdapter, and then provide the name of the stored procedure.
SqlDataAdapter MyDataAdapter1 = new SqlDataAdapter("EWO_ProductsByCategory", conn);
MyDataAdapter1.SelectCommand.CommandType = CommandType.StoredProcedure;
SqlParameter ParCateg = new SqlParameter("@CategoryId", SqlDbType.Int);
ParCateg.Value = tmpCategoryId;
MyDataAdapter1.SelectCommand.Parameters.Add(ParCateg);
SqlParameter ParMainCateg = new SqlParameter("@MainCateg", SqlDbType.Int);
ParMainCateg.Value = tmpMainCateg;
MyDataAdapter1.SelectCommand.Parameters.Add(ParMainCateg);
SqlParameter ParProdForm = new SqlParameter("@ProdForm", SqlDbType.Int);
ParProdForm.Value = tmpProdForm;
MyDataAdapter1.SelectCommand.Parameters.Add(ParProdForm);
MyDataAdapter1.SelectCommand.CommandTimeout = int.MaxValue;
MyDataAdapter1.Fill(DS, "Products");
//'Create a DataAdapter, and then provide the name of the stored procedure.
SqlDataAdapter MyDataAdapter2 = new SqlDataAdapter("EWO_ProductDetail", conn);
MyDataAdapter2.SelectCommand.CommandType = CommandType.StoredProcedure;
SqlParameter ParCategA = new SqlParameter("@CategoryId", SqlDbType.Int);
ParCategA.Value = tmpCategoryId;
MyDataAdapter2.SelectCommand.Parameters.Add(ParCategA);
SqlParameter ParMainCategA = new SqlParameter("@MainCateg", SqlDbType.Int);
ParMainCategA.Value = tmpMainCateg;
MyDataAdapter2.SelectCommand.Parameters.Add(ParMainCategA);
SqlParameter ParShipWeekA = new SqlParameter("@ShipWeek", SqlDbType.DateTime);
ParShipWeekA.Value = tmpShipWeek;
MyDataAdapter2.SelectCommand.Parameters.Add(ParShipWeekA);
SqlParameter ParAvailOnlyA = new SqlParameter("@AvailableOnly", SqlDbType.Int);
ParAvailOnlyA.Value = tmpAvailableOnly;
MyDataAdapter2.SelectCommand.Parameters.Add(ParAvailOnlyA);
SqlParameter ParProdFormA = new SqlParameter("@ProdForm", SqlDbType.Int);
ParProdFormA.Value = tmpProdForm;
MyDataAdapter2.SelectCommand.Parameters.Add(ParProdFormA);
MyDataAdapter2.SelectCommand.CommandTimeout = int.MaxValue;
MyDataAdapter2.Fill(DS, "ProdForms");
DS.Relations.Add("MyRelation", DS.Tables["Products"].Columns["StockSiPk"], DS.Tables["ProdForms"].Columns["StockSiPk"]);
Products.DataSource = DS.Tables["Products"].DefaultView;
Products.DataBind();
for (int i = 200; i > 0; i--)
{
//Nothing here just waiting toprevent timeouts -- not sure if this is really working
}
}
|
|
|
|
|
tip:
use PRE tags when posting code blocks, then someone might make an effort to actually read it...
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
Hi there.
I want to convert "Black" string to Brush.
For example something like this :
this.comboBoxColor.Background = (Brush)"Black";
How can we do it?
Can you help me ?
Freshman
|
|
|
|
|
This may work depending on the input string:
string colorName = "Black";
SolidBrush brush = new SolidBrush(Color.FromName(colorName));
You can find a list of available colors here[^].
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks Greeeg.
This code doesn't work in WPF.
I'm using WPF !
Freshman
|
|
|
|
|
Well, he's given you the only possible answer. That's how you get a color from a string, you need to build whatever brush type you need from there.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|