|
This appears to be a database issue and probably has nothing to do with C#.
|
|
|
|
|
hi, could anyone give me a clue on how to select multiple controls(say textbox forexample) by pressing ctrl key? Thanks in advance!
|
|
|
|
|
Please clarify what you are asking to do.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Your question isn't very clear.
If you mean selecting controls in design view, you can simply press and hold the Ctrl key, and click on the controls you wish to select.
Alternatively, you could just click and drag to select multiple controls (just like when you're selecting multiple icons/folders in Windows Explorer).
Kristian Sixhoej
"You can always become better." - Tiger Woods
|
|
|
|
|
If you are talking about adding controls to a collection at runtime, the following code will detect whether or not the CTRL key is currently pressed:
if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
{
MessageBox.Show("CTRL key is pressed.");
}
You could add an event handler to the Click event of each control you create so that you can detect if CTRL was pressed while it was clicked. FYI, you can use the same event handler for all your controls. And that event handler can add the control to the collection of controls.
|
|
|
|
|
thank you very much for the exact answer . And when you say control collection, do you mean "System.Windows.Forms.Form.ControlCollection"?
|
|
|
|
|
List<Control>, though ControlCollection might work too.
|
|
|
|
|
I guess that your means is :
When pressing the Ctrl button, click ten controls one by one, then this ten controls will all be selected.
right?
Result:
bool bCtrlPressing = false;
On Key Down event: if Ctrl press then bCtrlPressing is true.
On Key Up event: if Ctrl up then bCtrolPressing is false
On Mouse Down:
if bCtrilPressing is true, add this control to the selecting list.
|
|
|
|
|
I have a notepad text file that looks like this:
xxxxixxxxxcxxxxxxxxixxxxt
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
25 across, 19 down...
And some code to read in the text file:
FileStream fs = File.OpenRead("maptest.txt");
StreamReader reader = new StreamReader(fs);
string x = string.Empty;
while (!reader.EndOfStream)
{
int y = reader.Read();
char z = (char) y;
if (z == 'x' || z == 'c' || z == 'i' || z == 't') x += z.ToString();
}
char[,] map = new char[25, 19];
int index = 0;
for (int row = 0; row < 25; row++)
{
for (int col = 0; col < 19; col++)
{
map[row, col] = x[index];
index++;
}
}
My array "char[,] map = new char[25, 19]" is meant to store x and y cords of each character ie to find the first instance of the character "i" I can get its by referencing "map[4,0]".
My text reader is wrong and I need some help to read in the values into the array
|
|
|
|
|
Actually, don't you want the array to be [19,25], as in 19 rows of 25 characters ?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hey Mark, why do all your posts get a 1 vote? Does someone here hate you?
|
|
|
|
|
Yes, there appears to be very childish people around here. What a surprise.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
You have your columns and rows mixed up.
char[,] map = new char[25, 19];
int index = 0;
for (int row = 0; row < 19; row++)
{
for (int col = 0; col < 25; col++)
{
map[col, row] = x[index];
index++;
}
}
|
|
|
|
|
Thanks all works now
|
|
|
|
|
On an unrelated matter, why are you making a string that way?
You could use a StringBuilder, or even skip that step at all if you're only using it to fill the map (you could fill the map directly)
In this case it doesn't matter that much since the string is fairly short, but string concatenation inside a loop should generally be avoided..
|
|
|
|
|
If you create a custom collection by deriving from CollectionBase, is there an easy way to fire an event when one of the collection items is updated?
For example, any GUIs that care can subscribe to some sort of event that would be fired where an object that is a member of the collection is modified?
|
|
|
|
|
If you have created a custom class you can create whatever events make sense. For instance, in your override for the OnSet method fire off your custom event.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Not that I know of. There are two easy options.
1. If you are using .NET framework 3.5 then add a reference to WindowsBase to your project. You can then use System.Collections.ObjectModel.ObservableCollection<T> which has an event CollectionChanged which should do what you want.
2. Make your own generic class and implement ICollection<T> and possibly ICollection . You can simply wrap a List<T> in this class to make implementation easier. Now you have control over all items in/out of the collection so can raise custom events as you like.
[Edit]
I've just had a look at the CollectionBase class and you should be able to override the necessary methods as they are protected virtual and raise your own event(s).
OnClear, OnInsert, OnRemove, OnSet
All these also have a protected virtual OnxxxComplete method too.
[/Edit]
Dave
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
modified on Sunday, March 21, 2010 10:09 AM
|
|
|
|
|
hello
can any one give me a sample code of
creating a function or procedure in oracle
and then use it to return a datatable with tableadapter
thank you
|
|
|
|
|
Here[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Dear Friend,
I am working on GridView in c#. Getting a problem on dynamic add html in a GridView Columns. How can I make a dynamic template by coding??? Many thanks.
<br />
<br />
DataTable dt = new DataTable();<br />
dt.Columns.Add("Id", Type.GetType("System.Int32"));<br />
dt.Columns.Add("Detail", Type.GetType("System.String"));<br />
<br />
dr = dt.NewRow();<br />
dr["Id"] = id;<br />
dr["Detail"] = "<a href='home.aspx#" + id + "' >Detail</a>";<br />
dt.Rows.Add(dr);<br />
<br />
gridView.DataSource = dt;<br />
gridView.DataBind();<br />
|
|
|
|
|
Use a HyperLinkField;
HyperLinkField detailLink = new HyperLinkField();
detailLink.NavigateUrl = string.Format("home.aspx#{0}", id);
detailLink.Text = "Detail";
gridView.Columns.Add(detailLink);
You will also need to set the AutoGenerateColumns to false and create a BoundField for the id column.
|
|
|
|
|
FileSecurity ACL = File.GetAccessControl(InputFile);
ACL.AddAccessRule(new FileSystemAccessRule("Guest", FileSystemRights.Delete, AccessControlType.Deny));
ACL.AddAccessRule(new FileSystemAccessRule("SYSTEM", FileSystemRights.Delete, AccessControlType.Deny));
ACL.AddAccessRule(new FileSystemAccessRule("Administrators", FileSystemRights.Delete, AccessControlType.Deny));
ACL.AddAccessRule(new FileSystemAccessRule("Users", FileSystemRights.Delete, AccessControlType.Deny));
File.SetAccessControl(InputFile, ACL);
Im using the above code in a loop to server to stop files from being deleted from my RAID (Nothing critical just Movies) but it seems to make flip all difference apart from the flag in special permissions (Which means the ACL is being applied) setting the read-only property to true doesn't help either.
Can anyone suggest a solution ? AFIK the above should cover all users.
|
|
|
|
|
This will control access from within your managed application but will do nothing for another application or an unmanaged app.
What is causing the delete?
You could possibly use a service that instantiates a FileSystemWatcher and monitors for the delete event
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
No not other applications just the operating system and shares via the context menu or the delete button.
Basically i want the directories to remain untouched so any device can add files to the share but every file on the raid to be read only / undeletable.
AFIK i did the equivalent of this on my old nas (777 folders 755 files) so files can e added but not removed.
|
|
|
|