|
WebBrowser Control[^] is what you want.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
How do you go about documenting the implementation of an interface? Do you just copy the interface comment to your implementation? Skip documenting the implementation? Create a new unique comment for the implementation?
public interface IMyInterface
{
int GetSomething (int param1);
}
public class MyClass : IMyInterface
{
public int GetSomething (int param1);
{
}
}
I'm currently leaning towards reusing the interface comment and figured out how to have it auto-magically included in the implementation with the following code. NOTE: you'll need to make a post-build copy of your XML files and reference those otherwise you'll get a file in use error.
public class MyClass : IMyInterface
{
int GetSomething (int param1);
{
}
}
p.s. is there an easy way to paste code with special characters (< > &) so it automatically converts them to their encoded form?
-- modified at 16:36 Thursday 29th November, 2007
Todd Smith
|
|
|
|
|
That may depend on what the thing does, but probably start by copying the comment and maybe add detail.
public interface IDataSource
{
int GetSomething (int param1);
}
class DataBase : IDataSource
{
int GetSomething (int param1) ...
}
class WebService : IDataSource
{
int GetSomething (int param1) ...
}
|
|
|
|
|
Ok this should be simple.
I made a form, added a combobox (for selecting items to edit, not for updating fields), several textboxes, a few checkboxes etc. On formshow it connects to my database, draws down the existing data, no problem. All the records in the datatable that were the result of a query, I could select from, and the other databound components would display the records contents, no problem..... however.... when i add a new row, the combobox updates, but if i select the NEW item in it, all the databound objects are still pointing to the record to which I had selected prior, and if i make changes to their contents, it updates the fields associated with the priorily selected record, I can still select the original records and edit their contents just fine... but the NEW record's contents never display, and the record to which the databound objects are pointing, never change either... can someone please help before all my hair turns white ? LOL
the setup code that establishes databindings and populates the data table is as follows.
mySqlDataAdapter1.SelectCommand =
new MySql.Data.MySqlClient.MySqlCommand(
"SELECT *,CONCAT(ENTRY_NO,\":\", TYPENAME) AS DISPLAYVAL FROM FILEINFO.FILETYPE ORDER BY TYPENAME",
mySqlConnection1);
mySqlDataAdapter1.Fill(dataSet1);
ComboList = new DataTable();
ComboList = dataSet1.Tables[0];
comboBox1.DataSource = ComboList;
comboBox1.DisplayMember = "DISPLAYVAL";
comboBox1.ValueMember = "ENTRY_NO";
FILENAME.DataBindings.Clear();
FILENAME.DataBindings.Add("TEXT", ComboList, "TYPENAME");
DESCRIPTION.DataBindings.Clear();
DESCRIPTION.DataBindings.Add("TEXT", ComboList, "DESCRIPTION");
FILEEXT.DataBindings.Clear();
FILEEXT.DataBindings.Add("TEXT", ComboList, "EXTENSION");
RECLENGTH.DataBindings.Clear();
RECLENGTH.DataBindings.Add("TEXT", ComboList, "RECORDLENGTH");
RECLENGTH.CausesValidation = true;
ISRECDELIM.DataBindings.Clear();
ISRECDELIM.DataBindings.Add("CHECKED", ComboList, "IS_RECORD_DELIM");
ISFIELDDELIM.DataBindings.Clear();
ISFIELDDELIM.DataBindings.Add("CHECKED", ComboList, "IS_FIELD_DELIM");
ISFLATFILE.DataBindings.Clear();
ISFLATFILE.DataBindings.Add("CHECKED", ComboList, "IS_FLAT");
RECDELIM.DataBindings.Clear();
RECDELIM.DataBindings.Add("TEXT", ComboList, "RECORD_DELIM");
FIELDDELIM.DataBindings.Clear();
FIELDDELIM.DataBindings.Add("TEXT", ComboList, "FIELD_DELIM");
I have a button which is labeled new record, its click event handlers is as follows:
private void button3_Click(object sender, EventArgs e)
{
DataRow r = ComboList.NewRow();
r["ENTRY_NO"] = DBNull.Value;
r["TYPENAME"] = "NEW FILE TYPE";
r["DISPLAYVAL"] = "X: " + r["TYPENAME"].ToString();
ComboList.Rows.Add(r);
}
Code mapped to the datatables.oncolumnchanged event is as follows....
private void UpdateDisplayVal ( Object sender,
DataColumnChangeEventArgs e)
{
if (e.Column.ColumnName == "TYPENAME")
{
e.Row["DISPLAYVAL"] = e.Row["ENTRY_NO"].ToString() + ": " + e.Row["TYPENAME"].ToString();
}
}
The combobox updates with a value "X: NEW FILE TYPE", when i select a new item in it
none of the other bound objects update with the new value, as they do when i selected
the old item.
|
|
|
|
|
Meaning, it won't turn on. Says missing files, when ever file is there.
|
|
|
|
|
Hi,
you should make an effort to be specific.
The exact error message (or number), any extra information (maybe a stack traceback),
other symptoms, all these may help us help you.
Also an exact error message can be typed into Google and point to a solution.
If you're the author of a program that fails without being very specific at it, you should
improve your program by adding:
- checks for success after each system call
- displaying what goes wrong with all available detail
(e.g. GetLastError function)
Without additional information, no one will be able to help you except maybe by wild guessing.
PS: see my second tip below.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I ran into a different way of exiting an application (via the escape key) the other day...
<br />
protected override void KeyPress(object sender, KeyPressEventArgs e)<br />
{<br />
if ((int)(byte)e.KeyCode == (int)System.Windows.Forms.Keys.Escape)<br />
{ <br />
Application.Exit();<br />
}<br />
}<br />
What i'm wondering is what does the (byte) do?
The code works with or without it...
I took this code from a DirectX tutorial within the SDK, so I assume whoever wrote it knows what their doing.
Cheers,
Mark.
|
|
|
|
|
Hi Mark,
I'm using .NET 2.0 and KeyPressEventArgs does not have a KeyCode, but the KeyDown and
KeyUp events would offer it.
AFAIK KeyCode returns a Keys value, so you can compare directly, without casting.
The (byte) casting looks like an attempt to mask modifier keys such as SHIFT, ALT, CTRL
but I don't like the way it is done, and I am not sure it is relevant here either.
So I would try a simple if (e.KeyCode==Keys.Escape)...
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi
I'm very new to C# and although I have managed to work through creating a simple method for arrays which holds the results of a query with just one return field
I now want to store the results of a query with many records of 15 or more fields and I don't know whether this should be in some kind of array or in a collection, in either case I don't know where to begin. Can anyone help in as simple terms as possible please?
regards
kenwen
|
|
|
|
|
kenwen wrote: Can anyone help in as simple terms as possible please?
That might be difficult, wait.... here try this[^]
|
|
|
|
|
That looks to be the kind of thing I want thanks
|
|
|
|
|
Ummm... wouldn't that be a System.Data.Datatable ?
|
|
|
|
|
Hi,
You may try using ArrayList, the capacity of an ArrayList is the number of elements the list can hold. As elements are added to an ArrayList, the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling TrimToSize or by setting the Capacity property explicitly. Indexes in this collection are zero-based.
For more information on this you may use visit the following link:
http://msdn2.microsoft.com/en-us/library/system.collections.arraylist(VS.71).aspx[^]
I hope this helps.
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Hi John,
Sorry for the delay in replying been offline over the weekend.
Just tried the arraylist and it seems to do what I need.
thanks
for your help
regards
Ken Stevens
|
|
|
|
|
hi there still new to c# so forgive this simple question
but is there an operator i can use to perform OR/AND operations on strings
ie
if (currentFd.Name.ToUpper() != "SHAPE" || "FID" || "OID")
{
// do whatever
}
id prefer not to turn this into a case statement and embedded if statements seem pretty ridiculous as well, but i searched around and had no luck finding a solution. anybody out there help?? thanks in advance for helping a newbie
|
|
|
|
|
use the .Equals() method
if(currentFd.Name.ToUpper().Equals("SHAPE") || currentFd.Name.ToUpper().Equals("FID") || currentFd.Name.ToUpper().Equals("OID"))
{
}
...only use cascading if statements if you are really pissed off at your grader
-- modified at 14:39 Thursday 29th November, 2007
"I need build Skynet. Plz send code"
|
|
|
|
|
Alaric_ wrote: == and != can't be applied to strings in that way
What? It's not a problem with the == operator.
|
|
|
|
|
...let me rephrase....(in my opinion) == shouldn't be applied to strings in that way because strings are not actually value types....if you were checking it against null, then "str==null" would be acceptable because you would be comparing whether the value of the reference was equal to null or not. I did not intend to say that "==" and "!=" were causing his problems
...if you want to test whether str is equal to "some string value",
str = "some literal string value";
if(str == "some literal string value"){}
if(str.Equals("some literal string value")){}
the value of the reference to str IS NOT EQUAL to "some literal string value"
but the value stored by str IS EQUAL to "some literal string value"
"I need build Skynet. Plz send code"
|
|
|
|
|
understood..
thanks for clarification
|
|
|
|
|
Well I disagree, in my opinion:
if(str == "some literal string value"){}
if(str.Equals("some literal string value")){}
|
|
|
|
|
I second that.
The most readable syntax is the right one for me (provided it does what is intended).
And it also avoids the potential null problem.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I thought that == did the exact same thing as .Equals
And i don't mean the result is the same. I mean the actual comparison is exactly the same.
My current favourite word is: PIE!
I have changed my name to my regular internet alias. But don't let the 'Genius' part fool you, you don't know what 'SK' stands for.
-The Undefeated
|
|
|
|
|
Hi,
this is how I see it, after some experiments:
str=="abc" generates MSIL containing a call to the static method
String.op_Equality(string,string)
str.Equals("abc") generates MSIL containing a virtual call to the
instance method String.Equals(string)
when str is a valid (non-null) string reference, both methods are supposed to do
exactly the same.
But when str happens to be null, the first will succeed, whereas the second will
throw a NullReferenceException.
Given all this, I never plan on using the latter.
BTW: there also is the static method String.Compare with many overloads, yielding
more than just an equal/unequal result.
The C# compiler treats strings in special ways, to make life easier. To name a few:
- string literals (with double quotes)
- string comparison (the shorthand way)
- switching on a string.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
thanks for the prompt reply... but I have no problem using statements in such a way in c# in fact they are virtually the same. Still waiting for an answer regarding the or statement. thanks
"For reference types where == has not been overloaded, it compares whether two references refer to the same object - which is exactly what the implementation of .Equals does in System.Object."
|
|
|
|
|
String.Compare(string1, string2, false) == 0 is probably the more preferred method as it will not throw a null reference exception.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|