|
Thank you for your advices. They really helped me and the form. It doesn't have to struggle anymore.
|
|
|
|
|
you're welcome.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Luc Pattyn wrote: if you have those, don't forget to Dispose the ones you created
Hi, What if my app has values need to be passed? does this.Dispose() going to erase them?
Sun
|
|
|
|
|
Hi,
IMO this.Dispose() does not make any sense, an object cannot dispose itself, as it would have to be alive to execute the next line of code.
This is what I meant:
public void Paint(object sender, PaintEventArgs e) {
Graphics g=e.Graphics;
Font myFont=new Font(...); <<<<<<<<<<<<<<<<<<<<<<<
g.DrawString(..., myFont, ...);
...
myFont.Dispose(); <<<<<<<<<<<<<<<<<<<<<<<
}
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Luc Pattyn wrote: IMO this.Dispose() does not make any sense,
Hi,
Sorry if I said it wrong, but when I mentioned this.Dispose() , this = the main form. But thank you, Luc, I got your point. Again, I have another question, what if I set a new Font for one control, for example, btn_OK, am I doing it rightly by the code below:
btn_OK.Font = new Font(....);
...
btn_OK.Font.Dispose();
Thanks in advance!;)
Sun
|
|
|
|
|
Leapsword Sun wrote: btn_OK.Font = new Font(....);
...
btn_OK.Font.Dispose();
assuming all that is code in a single method, no it does not make sense: assuming the button is visible on some form, the font is in use, so you shouldn't dispose of it at that time.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Luc Pattyn wrote: assuming the button is visible on some form,
Hi, what if I create this button btn_OK dynamically in my codes then? Thanks for your patient so much!
Sun
|
|
|
|
|
I am trying to fill a collection with the names of the colums from an Excel sheet. The inner foreach fails with
"Unable to cast COM object of type 'System.__ComObject' to class type 'System.Data.DataColumn'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface."
What am I doing wrong here?
List<string> colColumns = new List<string>();
ApplicationClass ExcelApp = new ApplicationClass();
Workbook WorkBook = ExcelApp.Workbooks.Open(Header.SourceLoc, 0, true, 5, "", "", true, XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
foreach (Worksheet Sheet in WorkBook.Worksheets)
{
if (Sheet.Name.Trim().ToLower() == Header.SourceTable.Trim().ToLower())
{
foreach (DataColumn Col in Sheet.Columns)
{
string s = Col.ToString();
}
break;
}
}
Everything makes sense in someone's mind
|
|
|
|
|
Kevin Marois wrote: DataColumn Col in Sheet.Columns
This thing. WorkSheet.Columns is of type Range and you are trying to make it as datacolumn. I would suggest to have a for loop and then iterate and then populate your data columns.
If you are putting excel values in DataColumn and then in datatable, you should go for OleDB approach. That would give you the datatable right away.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Looking for libraries for threaded serial communication. Anyone have some links, free or relatively inexpensive.
|
|
|
|
|
Hi,
I'm unaware of any serial library, and if one existed, I would probably not use it. I use the SerialPort class directly, and adapt architecture, protocols, and code to the various needs I may have.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Do you find that the .net component is fast enough to perform at high baudrates, and handle other application processing of data from the serialPort?
|
|
|
|
|
Hi,
I used serial ports a lot before .NET existed, using standard Win32 functions.
From my .NET serial experience, I have no reason to claim .NET has added a lot of overhead to those functions, however I do not have proof to the contrary either.
BTW: Under high communication loads, I would not be inclined to use the DataReceived event; I'd rather use a separate thread with an outstanding Read. That way I'm in charge of how much data gets read and when it gets processed, as DataReceived lacks a clear specification.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
I use the SerialPort class a lot in my work, and haven't had any issues. One of my current projects uses 921600 baud (fastest you can set in HyperTerminal) and it's been performing fine.
Dybs
|
|
|
|
|
Hi every one, i'm trying to make a dictionary in C# in my country (Ethiopia) official language Amharic that means a dictionary that converts English to Amharic. I designed all words but it is difficult for me to store all English words that are used to be searched. Please guys help me in what format do i've to store those words?
Thank YOU SO MUCH
|
|
|
|
|
Maybe you can store all the words in a StringCollection and search in the collection for the desired word?
|
|
|
|
|
Hi,
that would have to be a Dictionary<string, List<string>> so the key can be an English word, and the value would be a list of Amharic words, as an English word may have more than one meaning and one translation.
However if you want to store metadata (such as noun/verb/...), you would have to define a class or struct Word , and then your dictionary becomes a Dictionary<Word, List<Word>>
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Thank u Luc Pattyn that is a good idea
|
|
|
|
|
you're welcome.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Luc Pattyn wrote: However if you want to store metadata (such as noun/verb/...), you would have to define a class or struct Word, and then your dictionary becomes a Dictionary<word, list<word="">>
This is less than optimal. In a large dictionary you'd have massive duplication in the List<word>'s. Probably the best option would be to do 2 dictionary<>'s and create a key/ID for the english words.
Dictionary<Word, List<int>> TranslationDictionary;
Dictionary<int, Word> EnglishDictionary;
The latest nation. Procrastination.
|
|
|
|
|
I agree.
BTW: Are you aware you inverted the translation? is there a reason for that?
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Of course I did. It's so I could... err... in order to... uhhh... because it's... FRIDAY!
The latest nation. Procrastination.
|
|
|
|
|
that's OK then
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
If you're worried about dupliaction, use a spell check tree.
|
|
|
|
|