|
Use LINQ to DataSet to query and join the 2 tables. The query result can be bound to the Grid or used to create a new DataTable for binding to.
|
|
|
|
|
Hi All,
I have an appliation that communicates with a hardware device attahced with the system. So far, the device had been attached using USB so the application was determining the PORT using Port Name.
Now, the newer device have 9-pin serial port. How can I now determine the Port number? I don't want to iterate through all the ports and send any command and analyse the response to determine the required Port.
Any suggestion or hint would be greatly helpful...
Regards,
-SIFAR.
|
|
|
|
|
use class "serialport".
SerialPort serialport1 = new SerialPort();
use this class and using this obj u can read port no....
ok.
TANIM
TAFIN
|
|
|
|
|
Thanks TAFIN.
I am aware about that class. My problem is how to determine the exact Port Number to which the device is attached without iterating through all the ports.
Regards,
-SIFAR.
|
|
|
|
|
There really is no way to determine that without iterating. Unless you make the user pick the port manually.
|
|
|
|
|
hey!!
im in a prob.i am trying to add some column and items in a list view.
but cant add a column even.Here is a code snippet. i am novice in C#. plz help.
Thanks in advance.
TANIM
Bangladesh
private void Form1_Load(object sender, EventArgs e)
{
ColumnHeader columnHeader1 = new ColumnHeader();
listView1.Columns.Add(columnHeader1);
}
|
|
|
|
|
Try This
listView1.View = View.Details;
listView1.Columns.Add("Column Name", 50, HorizontalAlignment.Left);
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Along with Abhijits answer you need to be aware that the SubItems need to be added for each item. It is possible to have say 5 columns and only 3 subitems for an item. The missing subitems are null and may generate an exception.
|
|
|
|
|
Thanks!!!
|
|
|
|
|
Give this a try:
ListViewItem lst1 = new ListViewItem(str, 0);
listView1.Items.Add(lst1);
modified 27-May-14 5:11am.
|
|
|
|
|
Hi, I have a program that opens an option form. For the options someone can basically list prices for various objects. I need to know how these prices can be remembered even after the program is shut down. I don't want to keep having to set the prices every time I run the program. Right now, I have a class which takes the prices and multiplies that by the quantity of an item. In that class I have static decimals. In the option form's button click I save a value to the class's static variables. Then I call those from the main form.
Thanks for your help!
|
|
|
|
|
I hear there's this new thing called a database...
(If the number of "objects" is small and steady, perhaps an XML file will suffice.)
|
|
|
|
|
You can store it in any storage location like DataBase, TextFile . When program is restarting read the content from the storage location.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Yeah, I pretty much feel like an idiot. I use a database for my asp.net apps, but for some reason it never occurred to me to use it for a windows form app. Anyway, thanks for the answer.
|
|
|
|
|
Ok so you have just added a new definition to not "thinking outside the box" - note the joke icon, this made me chuckle.
|
|
|
|
|
If those options are global or per user (application user), the best place to store them is a database; if the options are per machine, store them in a custom xml file.
|
|
|
|
|
If your list is something that can be thought of as application settings , put it there. The application settings are easy to manage.
Try to use but not abuse data bases (not even xml file dbs)
|
|
|
|
|
Hi, u can use resource file, as they are part of application and not stored outside of it. u can access them using stream when required, conditionally prices dont change often.if u use this u dont need DB and not even shared variables.
Avinash S. Godse
|
|
|
|
|
hello all.
I want to validate category name before insert all information about category into database.
The following condition is the way i want to compare:
Ex: ------------------------------------------------------------------------
| name in TblCategory | name in Text box | comparative result |
------------------------------------------------------------------------
| white bag | whitebag | existing |
------------------------------------------------------------------------
| whitebag | white bag | existing |
------------------------------------------------------------------------
| White Bag | white bag | existing |
------------------------------------------------------------------------
I use this following function in sql database:
BEGIN
IF EXISTS(SELECT TOP 1 *
FROM TblCategory c
WHERE (c.c_name=@name OR c.c_name=REPLACE(@name,' ',''))
AND c.c_id <> @id
)
SET @result=1
ELSE
SET @result =0
END
this give me bad result if TblCategory (white bag) and TextBox to compare has word(whitbag)...this can't compare to me
|
|
|
|
|
How does this relates to C#?
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
You can use a soundex search but it will not be a satisfactory solution. If the idiot user types whitbag then the user is an idiot (or a lousy typist), you are almost certainly not going to be able to catch all typos no matter what you try.
Another idea may be to use a soundex search and let the user select an existing category or force a new category.
|
|
|
|
|
Use this:
WHERE (REPLACE(c.c_name,' ','')=REPLACE(@name,' ',''))
|
|
|
|
|
REPLACE(c.c_name,' ','') this method is replace space of the field name(c.c_name) to select not replace resutl
can you give me any ideas?
|
|
|
|
|
I cannot understand what you are trying to say. Can you be more clear ?
|
|
|
|
|
ok, this is my original question:
I want to validate category name before insert all information about category into database.
The following condition is the way that i want to compare:
Ex: ------------------------------------------------------------------------
| name in TblCategory | name in Text box | comparative result |
------------------------------------------------------------------------
| white bag-----------| whitebag---------|---existing---------|
------------------------------------------------------------------------
| whitebag----------- | white bag------- |----existing--------|
------------------------------------------------------------------------
| White Bag-----------|--white bag ------|---- existing ------|
------------------------------------------------------------------------
I use this following function in sql database:
BEGIN
IF EXISTS(SELECT TOP 1 *
FROM TblCategory c
WHERE (c.c_name=@name OR c.c_name=REPLACE(@name,' ',''))
AND c.c_id <> @id
)
SET @result=1
ELSE
SET @result =0
END
this give me bad result if TblCategory (white bag) and TextBox to compare has word(whitbag)...this can't compare to me
then you you tell me to do this :
WHERE (REPLACE(c.c_name,' ','')=REPLACE(@name,' ',''))
but this replace is only replace my field name(c.c_name) but not give me validation to insert category infomation
|
|
|
|