|
thank you sir my meaning is same
If you can think then I Can.
|
|
|
|
|
I Did create empty windows Form, and I Put your sample, and it worked without any error.
Have you posted your actual code? If Not, please post actual foreach loop.
Where and How do you use and initialize String_Array and Flag?
What Exception do you get and at witch line?
|
|
|
|
|
i have found the solution for that:
the solution is : The language does not allow you to reassign a "foreach" variable. Even
if you could, it wouldn't update the contents of hte array. What do
you want to do here? If you want to change the values in the array,
then you will have to do somehing like.
for(int i = 0 ; i < arrfile.Length; i++)
{
str = arrfile[i]
}
If you can think then I Can.
|
|
|
|
|
hi there,
i am trying to bind a textBox with a MS-SQL table fiels in this way:
dataAdapter.Fill(dataSet, tableName);
textBox.DataBindings.Add("Text", dataSet.Tables[tableName], "someField");
the thing is, that while using dataAdapter.Fill() method, the textBox is really filled...BUT when i am making changes in the textBox the modification doesn't reflect in the DB.
what am i missing in order to make this bind 2-way???
thx!
|
|
|
|
|
You're probably not using WPF. I've never heard of text boxes magically doing this, and if they did, I still wouldn't touch it with a barge pole.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Until you've issued a dataAdapter.Update(), changes won't be "reflected in the DB".
"Data binding" deals with controls and sources of data "in memory" (in your case, the DataSet; in other cases, it might be a different type of object, such as an Entity Model query). To get the data from the "in memory" data source to the "data store" (i.e. the "Database") one needs to issue an Update() sometime; the type of Update being dependent on the data source.
|
|
|
|
|
i used this data adapter instance later on when the user clicks on some button.
the INSERT,SELECT,UPDATE,DELETE commands were set.
then :
dataAdapter.Fill(dataSet, tableName);
textBox.DataBindings.Add("Text", dataSet.Tables[tableName], "someField");
and then later on:
da.Update(dataSet, tableName)
doesn't work...
i read somewhere that this binding is not Bi-Directional.
never mind.. thx guys anyway.
eventually i used the SqlDataReader. simple, easy, and... works!
|
|
|
|
|
hi to all, i was wondering if i can get some help,
i'm srawing on tabs of tab control item that has string and a-16X16 pixel icon of cancel button,
(just like the tabs in a regular browser that have a small button to close the tab).
anyway, i'm tring to make the icon on the selected tab to be red and the other tabs gray.
here is the code:
private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)
{
Image img1 = new Bitmap(Application.StartupPath + "\\icons\\cancelGray.png");
Image img2 = new Bitmap(Application.StartupPath + "\\icons\\cancelRed.png");
Rectangle r = e.Bounds;
r = this.tabControl1.GetTabRect(e.Index);
r.Offset(2, 4);
Brush TitleBrush = new SolidBrush(Color.Black);
Font f = new Font("Microsoft Sans Serif", 8.0f);
string title = this.tabControl1.TabPages[e.Index].Text;
e.Graphics.DrawString(title, f, TitleBrush, new PointF(r.X, r.Y));
foreach (TabPage tp in tabControl1.TabPages)
{
if (tp == lastSelected) //LAST SELECTED IS THE THE CURRENT TABPAGE THAT SELECTED.
e.Graphics.DrawImage(img2, new Point(r.X + (this.tabControl1.GetTabRect(e.Index).Width - _imageLocation.X) - 7, _imageLocation.Y));
else e.Graphics.DrawImage(img1, new Point(r.X + (this.tabControl1.GetTabRect(e.Index).Width - _imageLocation.X) - 7, _imageLocation.Y));
}
}
the problem is that the changing colors of the tabs is not correct, i can't figure why when i'm clicking one tab the other is change..
thanks,
modified 31-Dec-20 21:02pm.
|
|
|
|
|
Hi,
in general events may fire more often than you would expect, so it is unwise to use status information from elsewhere when this can be avoided, as such data might be incorrect.
More in particular: why are you using your lastSelected when you have TabControl.TabPages[TabControl.SelectedTab] which is bound to always be the correct current page?
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
what do you suggest instead of the foreach?
and i tried the tabControl1.SelectedTab instead of the lastSelected before, it's only a bad try to fix the problem.
modified 31-Dec-20 21:02pm.
|
|
|
|
|
sagiko wrote: what do you suggest instead of the foreach?
Nothing.
I can't help you any further lacking precise scenarios and symptoms.
sagiko wrote: it's only a bad try to fix the problem
that does not help at all.
To be as vague as you are: fix the problem.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
modified 31-Dec-20 21:02pm.
|
|
|
|
|
Hi all.
I am trying to delete a directory and using
Directory.Delete("some_file_path");
These works just fine if the directory has no files in it but if it has any file, it does not get deleted. What should i do to delete a directory with or without a file?
Wamuti: Any man can be an island, but islands to need water around them!
Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.
|
|
|
|
|
Hi,
write code to delete any files in the directory tree you want to delete. There are basically two ways:
1. ask a list of all files with a GetFiles(path, "*", SearchOptions.AllDirectories), delete all of them, then delete all (now empty) folders and subfolders using Directory.Delete(path, true);
2. write a depth-first recursive method that locates files, deletes them, then deletes the subfolder; this is slightly harder but doesn't get the big memory penalty on huge folders.
NB: since .NET 4.0 there are new methods that relieve the memory consumptions in (1)
PS: there is bound to be a native method that does it all; calling it would require some P/Invoke.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Luc Pattyn wrote: there is bound to be a native method that does it all;
I looked, and was surprised to find that there wasn't one in the Win2K native API. Even then it was still necessary to empty a directory before removing it. I haven't looked at this book (Windows NT/2000 Native API Reference) in a decade, and found it amusing to see ZwCreateMutant and ZwReleaseMutant. I wonder if that was part of Bill's plan to take over the world? It would explain a lot of things about Congress in recent years...
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
I think this will do it.
DirectoryInfo d;
d.Delete(true);
|
|
|
|
|
Which directory will this code delete ?
|
|
|
|
|
There is an overloaded Delete method that takes a boolean parameter 'recursive' to specify that you want the delete operation to be recursive, that is, to delete all subdirectories, files, etc. in the specified path.
This code will do the trick.
Directory.Delete("some_file_path", true);
|
|
|
|
|
Hello,
how can i work with my JS-Objects, which i get over invoking JS in the WebBrowser-Control in my C#-Application? Is there any serializer? I get something like a "DOM-OBJECT" back from JavaScript, but can't work with it. So is there any possibility for example putting the Object into a string/xml-file put this through my invoked script and deserialize that xml-file or string into c#-classes?
Has somebody experience in doing that or working with that objects?
Thanks
|
|
|
|
|
Use the CreateJsonReader and CreateJsonWriter methods of the JsonReaderWriterFactory class to map JSON from / to XML.
|
|
|
|
|
Hello,
and how to use it? Because when i doing HtmlDocument.InovkeScript(...) i get as a return value a "object"... and if i try out which type it is i get "DOM-Object" or "COM-Object" (i'm not sure now), so how do i use this object which i get back in this JsonReader? Because in tutorials for this JsonReaderWriterFactory everyone uses some XmlDocuments...
Thanks
|
|
|
|
|
JSON objects consist of "name / value" pair elements.
The System.Xml.XmlDictionaryReader (and not "XmlDocuments") that you get back from the Factory consists of "name / value" pairs.
You use the Factory to read the JSON object as a "stream" and get back a XML reader which you then read using the .Read() method. Each "read" will get you a node with a Name, Value, NodeType, etc. Sometimes the Value contains nothing and you need to use one of the "Node.Readxxx" methods (e.g. ReadString()).
If you don't know what's in the JSON object, you're first go-around would be to simply dump everything for each node.
|
|
|
|
|
I am working with an application that has a background worker thread.
Passing infroamtion back is easy by using ReportProgress .
I can cancel the thread but is there a simple way to make calls to it to pass data? I have looked at message queues but it looks like overkill.
Recommendations?
Thanks.
[Update] System.Collections.Queue will do what I need plus it has a Synchronize method for thread safety.
modified on Friday, November 27, 2009 7:01 PM
|
|
|
|
|
yetch - if a noob had asked this question I'd have said - 'needs more design' - I think your options are a shared & thread-safe queue or similar or message queues Elaine - while it may 'look like overkill' when you're dealing with threads etc, its the tendency to cut-corners that brings people undone with locking etc
just my 0.02c worth
'g'
|
|
|
|
|
Trollslayer wrote: Passing infroamtion back is easy by using ReportProgress
That's correct for GUI output, for anything else communication with another thread needs one of many things (shared objects with locks, messages, queues, etc), the best pick very much depends on what kind of app it is, what kind of threading effects you have in mind. So if you want specific advice, tell us a lot more!
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|