|
Search for "app.config read key"[^] and you will find a lot of information.
---
single minded; short sighted; long gone;
|
|
|
|
|
hi
i'm working with DataTables. my DataTable contains the record from a DB table in row and column format. i want to access the record value on a specific location in the datatable by specifying the row and column number, and then retrieving the value on that particular locaion.
how can i do it??
can u plz tell me the syntax
regards
Saira
|
|
|
|
|
Saira Tanwir wrote: my DataTable contains the record from a DB table in row and column format.
What do you mean by "row and column format"?
Saira Tanwir wrote: i want to access the record value on a specific location in the datatable by specifying the row and column number, and then retrieving the value on that particular locaion.
Sorry, I misread what you were saying - I thought you were asking about the table in the database...
In a DataTable you have a collection called Rows. You can access a row by its index
DataRow row = myTable.Rows[rowIndex];
You can then access the column by a column index.
object value = row[columnIndex];
You can't. Databases don't work like that. You can fake it if it is really what you need, but you'll need to add some sort of rownumber column to the table and it will be a real nightmare trying to keep it correctly updated.
A database works on "sets" of data. There is no built in order in a set. You can get the illusion of order by taking into account implementation details of specific databases. For example, in SQL Server you can create a clustered index (usually on the primary key) which will ensure that the data is physically inserted in the order of that index. You can use the ORDER BY clause to sort the rows as they are extracted from the database.
But at the end of it all there is no specific "get me row 42" functionality. SQL Server 2005 has some additional tools to help make faking this easier, but it is still an illusion.
-- modified at 13:11 Sunday 11th February, 2007
|
|
|
|
|
Hi, I am building a text editor, and I would like to undo the last thing done.
so, I used the Undo() method, but found it undoes everything changed, how can I set it so it only changes the LAST thing done?
My code was:
<br />
<br />
rchTextCode.Undo();<br />
<br />
|
|
|
|
|
Err..i haven't realy tested it but how about....rchTextCode.Text.Undo()?
of cource it'll delete everything if u tell it to undo the entire textbox and not the text it in...
|
|
|
|
|
sharpiesharpie wrote: Err..i haven't realy tested it but how about....rchTextCode.Text.Undo()?
This won't work as the String class defines no Undo method.
sharpiesharpie wrote: of cource it'll delete everything if u tell it to undo the entire textbox and not the text it in...
The Undo method only operates on the text of the text box (see the documentation). He meant that it undos all changes applied to the text and not all changes applied to the text box itself.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Actually, there is a rtf.Text.Undo method...
|
|
|
|
|
Mmh, I don't know where you get that.? The RichTextBox.Text property returns a String instance and the String type definitely has no Undo method.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Search the articles for "undo". There are some that cover this topic.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I tried and got the Undo() not to undo the whole textbox, but only the latest entry. What I did was I clicked on another object, then clicked on the textbox and added more text. You can probably achieve multi-stepped undo by playing a bit with the TextChanged event from the RichTextBox and changing focus.
Internet - the worlds biggest dictionary
|
|
|
|
|
Hello, I am creating a control that shows an image and a reflection of this one, very similar to which can be seen in the Windows Photo Gallery of Vista Windows: (the miniature to the right)
http://www.winsupersite.com/images/showcase/winvista_rc1_best_12.jpg
The problem is that when attempt to draw an image that is losing opacity, that is to say, to draw degrading that is diminishing the opacity of the reflected image. Since I can do this?
Greetings, sorry for my bad English
|
|
|
|
|
I have a class with a function that returns an ArrayList.
The problem is that I don't want any client that calls the function to be able to add or delete items from the ArrayList. I want to force the client to use my class' other functions to make any modifications (because related data has to be updated).
Unfortunately, speed is an issue, so I can't just copy the ArrayList and send the copy. Also, a copy would allow the client to think he is making a change when it is actually being ignored. I'd prefer him to get a compile error if he calls Add(), for instance.
I can't find any C# syntax that can make a returned value (or a returned parameter) read only. (The C# "readonly" syntax won't let the client replace the ArrayList with another, but WILL let the client change the content of the ArrayList, and so it is insufficient).
Any ideas would be appreciated.
Mark
11 Feb 2007
|
|
|
|
|
Instead of returning the ArrayList itself you could return an enumerator for the ArrayList . Take a look at the ArrayList.GetEnumerator method.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
If the only action you want to offer is enumeration, return an enumerator.
If you want to offer a larger subset of ArrayList functionality, create your own
class that:
- either inherits from ArrayList and hides the properties/methods you dont
want to offer,
- or contains an ArrayList and makes public the enumerator plus those extra properties/
methods you want to export.
Luc Pattyn
|
|
|
|
|
Thanks to you both who responded.
I couldn't figure it out without you.
For others interested, here is a minimal solution class which seems to work so far. You may want to add other properties or functions, but this is what I need for now.
I call it a Firm List since, for the user only, the array size is no longer variable but is firm (solidified). The user can read and use each item in the list, but can't make the list contain a different item nor change the number of items in the list.
using System;
using System.Collections;
namespace FreeForAll {
public class FirmList : IEnumerable {
ArrayList foundation;
public FirmList(ArrayList source) {
foundation = source;
}
public IEnumerator GetEnumerator() {
return foundation.GetEnumerator();
}
public bool Contains(object item) {
return foundation.Contains(item);
}
public int Count {
get { return foundation.Count; }
}
}
}
Here is how, within another class, I return a FirmList as property "SomeList". Within this class, I have full accees to the ArrayList itself and all of its abilities.
class A {
ArrayList TheRealList = new ArrayList();
FirmList TheFirmList;
A() {
TheFirmList = new FirmList(TheRealList);
}
...
void SomeFunctionThatAddsMembersToTheArrayList() {...};
...
public FirmList SomeList {
get { return TheFirmList; }
}
}
And, finally, here is how some other code might use it, just like and ArrayList is used:
A aaa = new A();
aaa.SomeFunctionThatAddsMembersToTheArrayList();
FirmList list = A.SomeList;
foreach (object o in list) {
...
}
WriteLine("{0}", list.Count);
if (list.Contains(...)) {...
Hope this helps someone else.
Mark
|
|
|
|
|
In C# you can't mark reference types as readonly.
However you can Encapsulate ArrayList inside a class and provide restricted access to it through methods, properties. You mentioned that speed is an issue otherwise you could have simply returned a clone to it.
|
|
|
|
|
Hi,
I have created a little button on the form called "Close", and when a user clicks it, it displays a messagebox saying "Do you really want to quit?" with an Ok and a Cancel. Then if they click Ok it does : this.Close(); and if not it doesn't do anything.
Now, I want to be able to get data from the X (Close button) on the form to display the same text box or disable the X (Close button) so users have to use the close button that I have created.
Any way of doing this?
Thanks.
|
|
|
|
|
Put all code that show the message box and eventually cancels the closing operation into the event handler for the FormClosing event and inside the button Click event handler simply call the Close method of your form.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
About the button, instead of the Close function, try using the Application.Exit function, the Close one seems to not work in many occasions.
And for the x button, i thought this might be a good think to know myself, and i made some research and this is what i came up with:
there's an event in frameworks 1.1 which is called Closing (which later became FormClosing in frameworks 2), so you use the event (this.FormClosing +=...) and in the event you can use:
e.Cancel = true;
this also stops it from closing with the F4 key, so you can do like so:
first, define the event:
<br />
this.FormClosing += new FormClosingEventHandler(MyForm_FormClosing);<br />
and then in the event do something like this:
<br />
void MyForm_FormClosing(object sender, FormClosingEventArgs e)<br />
{<br />
DialogResult a = MessageBox.Show("Are you sure you want to close the program?","Cancel",MessageBoxButtons.YesNo);<br />
if (a == DialogResult.No)<br />
e.Cancel = true;<br />
}<br />
And as for canceling the minimize and maximize buttons? how about just disabling them? or just use the Form.Resize event.
hope it helps.
-- modified at 10:35 Sunday 11th February, 2007
|
|
|
|
|
Thankyou, that helps a great deal. Thankyou for all the effort you put in to finding out about it also.
|
|
|
|
|
I just tried it out, it is amazing, thankyou very much. Except I don't understand the:
this.FormClosing += new FormClosingEventHandler(MyForm_FormClosing);
VC# EE just gave me a load of errors on that, and I don't quite know what it's doing anyway.
Well, thanks for the great help.
|
|
|
|
|
Can you please say what the errors are?
|
|
|
|
|
Hi, I need a little help.
I am wanting a message such as "Do you really want to quit?" to be displayed when a user clicks the X (close button) in the corner of the form. I have tried some methods that just haven't worked, as I do not know how to make the Close(); function display a bool to then be used in an if statement.
Any ideas?
Thanks.
|
|
|
|
|
you can use the FormClosing event to check if the user really wants to close the window...
cellardoor
|
|
|
|
|
Thankyou for your help, it works now
|
|
|
|