 |
|
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid..
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
|
 |
Lets say I have a form where someone can catalog a multiple people's Name and their State and City?
Assume I already have all the State/Cities in database. (a table for each state, with cities listed in each table)
The Name field will be a TextBox. And the State & City fields will be ComboBox (DropDownLists).
One row (for the entry of one person) already exists in the form. But I want the user to be able to dynamically add rows of entries by pressing an "Add Person" button.
The next step is where I'm struggling. In each dynamically added row of fields, I would like the second ComboBox (Cities) to be populated depending on which State is chosen in the first Combo Box. Also, the Cities ComboBox will remain disabled until the State ComboBox is chosen.
My code looks something like this:
public ComboBox cbState;
public ComboBox cbCities;
public static int NumberOfPeople = 1;
private void btnAddNewPerson_Click(object sender, EventArgs e)
{
NumberOfPeople++;
TextBox txtPerson = new TextBox();
txtPerson.Name = "Person" + NumberOfPeople;
Panel.Controls.Add(txtPerson);
cbState = new ComboBox();
cbState.Name = "State" + NumberOfPeople;
cbState.Enabled = true;
cbState.DropDownStyle = ComboBoxStyle.DropDownList;
Panel.Controls.Add(cbState);
cbCity = new ComboBox();
cbCity.Name = "City" + NumberOfPeople;
cbCity.DropDownStyle = ComboBoxStyle.DropDownList;
cbCity.Enabled = false;
cbCity.SelectedValueChanged += new System.EventHandler(this.ChangeState);
Panel.Controls.Add(cbCity);
}
private void ChangeState(object sender, EventArgs e)
{
..... Don't know how to properly identify the dynamically created City ComboBox that is in the same row as the State ComboBox that was just changed, and manipulate/populate it.....
}
Anyone able to help me solve this issue??
I'd greatly appreciate it!!
|
|
|
|
 |
|
 |
You might be able to do that sort of thing with a DataGridView.
But, personally, I find it to be a rather poor design. I would prefer that the "Add Person" button brought up a dialog. One benefit of this is that the user can cancel the entry without affecting the form (I assume that the way you described would require removing the added controls).
How you display the list of "people's Name and their State and City" would likely need to change as well -- I would probably use a TreeView rather than a bunch of TextBoxes and ComboBoxes.
|
|
|
|
 |
|
 |
If we have 2 form (Form1 & Form2) whitin a project
and we added an object (for example textBox1) to
Form1, how can we access to textBox1 from Form2.
i have done this in form2 by these codes
{
Form1 fr = new Form1();
.
.
.
}
but fr doesn't show textBox1 durring writing codes.
i suppose fr.textBox1 must be correct but it is not.
please tell ne how can i do that.
|
|
|
|
 |
|
 |
The simplest but wrongest way would be to make the TextBox public.
A better way is to make a public property that allows the other form to get and/or set the Text property of the TextBox.
There are other ways that may be more appropriate to your situation, but we would need to know more about what you are trying to do.
However you do it, you may have to protect against cross-thread access problems.
|
|
|
|
 |
|
 |
I want to get the properties value of that object and change it to
a new value as I want.
|
|
|
|
 |
|
 |
You would have to change the access modifier for the textbox.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
 |
|
 |
by changing the modifier I only can get the properties of
that object (the values can be read) how can we set the
properties to a new value?
|
|
|
|
 |
|
 |
I'm working on a custom Attribute. What I'd like is to have it take a parameter (e.g. [MyAttribute(foo)]), but the type I want to use isn't allowed (non-constant).
So, I made my Attribute abstract and derived other Attributes to specify the desired values:
class FooAttribute : MyAttribute
{
public FooAttribute() : base ( foo ) {}
}
class BarAttribute : MyAttribute
{
public BarAttribute() : base ( bar ) {}
}
This works as expected except that instances of both derived Attributes can then be applied and they don't get flagged as duplicates (of MyAttribute); from a certain point of view, AllowMultiple=false should disallow multiple instances of the base class. In practice this doesn't happen, and that's understandable, but I want to find a way to get it to work that way.
I investigated the TypeId property thinking that would work, but it doesn't seem to.
Has anyone here happened upon this situation and found a solution?
Currently my code is just using the first instance of MyAttribute it finds, but I'm considering having the code throw an Exception if it finds multiples -- does anyone here have an opinion on which course of action is better?
|
|
|
|
 |
|
 |
I am making a program in which I established connection with sql server using DSN. I am using ODBCConnection class. I want to check that, DSN which is created is for access or sql server. I did google but not getting helpful information. I am using c# and visual studio 2008. Thanks.
|
|
|
|
 |
|
 |
Unless you are developing your program to work with both -- as in using Access for testing, but SQL Server for production, then I don't really see a need to do this.
If you are doing that, then I might suggest that you create a table with that information and query it.
If, on the other hand, you are given a Connection and want to determine which it is, then the best I can say is to use the GetSchema method and examine the resultant table for clues.
|
|
|
|
 |
|
 |
I need to validate dsn name that it is valid or not. Like we can choose any dsn name which is for access, excel, or sql server.
|
|
|
|
 |
|
 |
If you want to check whether or not a given DSN points to your database, then I suggest making a Connection, calling GetSchema, and looking for your tables.
|
|
|
|
 |
|
 |
Hi All,
I have a printed document with lots of check-boxes, I must automatically detect which check-boxes are marked, and save these into a database. (Using C#)
Can anybody give me some hints where to start digging or examples of how I should start on this task.
Thanks alot.
|
|
|
|
 |
|
 |
Certainly willing to try
If the images will be obtained from a scanner, I'd suggest that you first implement code that will detect the skew angle and correct it. I seem to remember adapting some code with a name of gmeDeskew or something like that.
Next, you'll want to define the areas of interest. That is, the areas that will contain check-boxes that should be examined. Since different skew angles will result in images of slightly different sizes when deskewed, I'd suggest that these areas are defined using percentage of document width/height, as opposed to being defined in terms of number of pixels.
Once you have correctly deskewed the image and identified the areas of interest, you'll want to scan the image line-by-line, row by row to determine areas likely to contain check-boxes within your area of interest. Once done, examine the heck-boxes by simply counting the number of percentage of pixels that are below a certain brightness (you'll have to determine this threshold)
I coded an app once that would take scanned images of (college) attendance sheets, identifying the class name/week from a barcode, the student IDs from barcodes, then finally - the student attendance from manually colored 'radio buttons'
With this method, I was able to take an example image (at 1/4 scale as it happened) then deskew it and draw rectangles around each of the 18 barcodes for student ID, the 18 attendance scores for the students, the class name barcode and the class date barcode.
Then when I used full size images all of my areas of interest remained aligned correctly. (Using percentages of image size GREATLY improved the accuracy of the placement of the areas of interest onto each successive image. Prior to that idea, it was very difficult to be sure that I was going to examine the pixels that made up the parts of the image I was interested in)
Something else to consider is "pattern matching", or put simply - the comparing of pre-existing images with portions of the scanned document. You could simply use two images - one of an empty square and another of a check-box with a cross/dot/dash inside it. This should be effective because regardless of the style of marking, an empty box is always going to more closely resemble the saved image you have of an empty box (rather than the checked-box).
It's an interesting topic, OMR. (optical mark recognition) Enjoy!
|
|
|
|
 |
|
 |
Hello guys!
I am trying to use the following code to send an email to a mail server over a tcp connection. The code works great, however, when I try to send an email to someone, the receipt of my Email alwyes gets unknown sender(From). Am I missing something?
TcpClient SmtpServ = new TcpClient("smtp.my.com", 25);
string Data;
byte[] szData;
string CRLF = "\r\n";
try
{
NetworkStream NetStrm = SmtpServ.GetStream();
StreamReader RdStrm = new StreamReader(SmtpServ.GetStream());
Console.WriteLine(RdStrm.ReadLine());
Data = "HELO server" + CRLF;
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData, 0, szData.Length);
Console.WriteLine(RdStrm.ReadLine());
Data = "MAIL From:" + " me@test.com" + CRLF;
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData, 0, szData.Length);
Console.WriteLine(RdStrm.ReadLine());
Data = "RCPT TO: " + "me@my.net" + CRLF;
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData, 0, szData.Length);
Console.WriteLine(RdStrm.ReadLine());
Data = "DATA" + CRLF;
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData, 0, szData.Length);
Console.WriteLine(RdStrm.ReadLine());
Data = "SUBJECT: my subject\r\n\r\n";
Data += "Hello there!\r\n";
Data += ".\r\n";
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData, 0, szData.Length);
Console.WriteLine(RdStrm.ReadLine());
Data = "QUIT" + CRLF;
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData, 0, szData.Length);
Console.WriteLine(RdStrm.ReadLine());
NetStrm.Close();
RdStrm.Close();
Console.WriteLine("Close connection");
Console.WriteLine("Send mail successly..");
}
catch (InvalidOperationException err)
{
Console.WriteLine("Error: " + err.ToString());
}
Thanks,
|
|
|
|
 |
|
 |
The email address in the MAIL FROM: and RCPT TO: lines should be bounded with < and > characters like this:
"MAIL From:" + " <me@test.com>" + CRLF;
I also notice that you are ignoring all server responses so you cannot be sure your message is being accepted correctly. You may also like to consider using the SmtpClient()[^] class to process your mail.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
 |
|
 |
Hello Guys,
We are developing an antispyware program in .net and i want to register my product for listing it into windows security center. I Searched a lot about it and got some idea that it can be done through WMI by \\root\SecurityCenter2 namespace and antispywareproduct class. But all i found was to get the information for antispywareproduct class.
Can any one tell me how to add my product to this table.
any ideas will be a great help.
Regards
abhinav
|
|
|
|
 |
|
 |
Hello all,
I found this link .NET TWAIN image scanner[^] on code project, but When I press acuqire it opens a window from my scanner
when I press cancel on it, the whole application get freezed. How to solve this???
plzz
Thx
|
|
|
|
 |
|
 |
The best place to ask that is in the forum at the bottom of the mentioned article.
If you post there, the author will be notified. He is the person that more likely than others can help you.
Ciao,
luker
|
|
|
|
 |
|
 |
Hi all.
I'm now developing a website that connect to Postgre SQL database. I used NpgSQL.DLL to connect from C# to database. I also finished testing this project in my local pc, it worked well. But unfortunately it did not work well in server. Some errors in connecting to server happened.
These errors happened when website had much people logged in and began using database query functions ( select, update, delete .. ). I think errors begin from codes in connect database functions. but i still can not fix it. this is my connecting database codes.
------ codes connects database ---------
-- Connect.cs file.
public static void connectDB()
{
try
{
conn.ConnectionString = connection;
conn.Open();
}
catch
{
}
}
public static void closeConnectDB()
{
conn.Close();
}
public static int ExecuteQuery(string SQL)
{
try
{
connectDB();
NpgsqlCommand cmd = new NpgsqlCommand(SQL, conn);
return cmd.ExecuteNonQuery();
}
catch
{
closeConnectDB();
return 0;
}
}
public static DataSet SelectQuery(string SQL)
{
DataSet ds = new DataSet();
try
{
connectDB();
NpgsqlDataAdapter nDa = new NpgsqlDataAdapter(SQL, conn);
nDa.Fill(ds);
return ds;
}
catch
{
closeConnectDB();
return ds;
}
}
----------------- use to execute these codes --------
....
--- calling functions files.
try
{
string strTest = "Select * from abc where .. ";
DataSet ds1 = new DataSet();
ds1 = Connect.SelectQuery(strTest);
if (ds1.Tables[0].Rows.Count > 0)
{
}
else
{
int kq = Connect.ExecuteQuery(strInsert);
if (kq > 0)
{
int kk = Connect.ExecuteQuery(strUpdate);
kk = Connect.ExecuteQuery(strUpdate2);
strHTML = "OK";
}
}
}
catch
{
strHTML = "errors.";
}
finally
{
int kk = Connect.ExecuteQuery(strUpdate);
kk = Connect.ExecuteQuery(strUpdate2);
strHTML += "-- Sub Finally";
}
-----------------End calling function---------------
Here sometimes it worked well but sometimes catched errors.
Can you help me? thanks and regards.
|
|
|
|
 |
|
 |
Don't just swallow exceptions, at the very least you should log them to console or a log file so you can look at the stack trace and exception message. Those error messages will almost certainly give you a big clue as to the problem.
|
|
|
|
 |
|
 |
Hi everyone,
I want to integrate a C# application for paperless billing with a retail billing machine (those which are used in shopping malls for generating bills). Is there any way it can be done? Did not get any information about it on Google.
-Please help.
|
|
|
|
 |
|
 |
tahernd wrote: I want to integrate a C# application for paperless billing with a retail billing machine
What software exists in this machine and what interface(s) does it provide (both software and hardware) for connection with other applications?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
 |