|
This shouldn't be a problem. You'll just need to add the three JAR files to the classpath, and proceed as I explained previously. If you don't know what's the main method, check the MANIFEST.MF file inside the main JAR, where you'll find it mentioned. If not, you'll find it somewhere in the batch file, but you may have to dig deeper.
(You could post the batch file if you want, and I'll try to help you with it.)
|
|
|
|
|
Hi
I have a datagrid and I would like to either replace zero's with a space or suppress them. I have tried just putting in a space but that did not work. The field used to have -Infinity in it so I forced a zero with this line
if (Grid_Property.Rows[i].Cells["pDiff"].Value.ToString() == "-Infinity")
{
Grid_Property.Rows[i].Cells["pDiff"].Value = "";
}
I tried to add to string in the if statement but that did not work see below
if (Grid_Property.Rows[i].Cells["pDiff"].Value.ToString() == "-Infinity")
{
Grid_Property.Rows[i].Cells["pDiff"].Value.ToString = "";
}
Any help would be appreciated
|
|
|
|
|
One way to do what I think you want to do is to handle the CellFormatting Event of the DataGridView
Something like this.
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.Value == null)
{
return;
}
DataGridViewColumn col = this.dataGridView1.Columns[e.ColumnIndex];
if (col.DataPropertyName == "pDiff")
{
if (e.Value.ToString() == "-Infinity")
{
e.Value = "";
e.FormattingApplied = true;
}
}
}
Hope this helps, or, I have at least understood your problem correctly.
Henry Minute
If you open a can of worms, any viable solution *MUST* involve a larger can.
|
|
|
|
|
Hi Thank you for the reply, I tried the code but it does not seem to be recognized I think it is because I have to double click the event and then add the code? I have real newbie question, how do I find the events to add. I did it before but can't seem to remember. Also if my datagrid name is Grid_Property where would I insert than in your example. Sorry for the beginner questions.
Thanks
|
|
|
|
|
Ok. We all have to start somewhere.
1. Make sure your Form with the DataGridView is visible in the designer with the DataGridView selected.
2. Make sure that you can see the Properties Window. If you can't then select it from the View Menu in VS or, a good tip, press F4.
3. At the top of the Properties Window there are several icons, click on the lightening bolt. This will take you to the events for the selected control, hopefully
your DataGridView . If not select it now.
4. The events can be organised in many ways. Alphabetically or in categories for example, so I cannot tell you exactly where the CellFormatting event
will be on your system. Search for it, and double click on it.
5. The designer will switch to code view with an empty event handler method for the CellFormatting event. Like this:
private void Grid_Property_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
}
6. Put your code between the braces. Your code should look like this:
if (e.Value == null)
{
return;
}
DataGridViewColumn col = this.Grid_Property.Columns[e.ColumnIndex];
if (col.DataPropertyName == "pDiff")
{
if (e.Value.ToString() == "-Infinity")
{
e.Value = "";
e.FormattingApplied = true;
}
}
Try that.
Henry Minute
If you open a can of worms, any viable solution *MUST* involve a larger can.
|
|
|
|
|
That worked, Thank you very much for the reply, and the guidence
|
|
|
|
|
Given the following code:
FileSystemWatcher m_watcher = new FileSystemWatcher();
private void MyMethod()
{
m_watcher.BeginInit();
m_watcher.Filter = "*myfile*.*";
m_watcher.IncludeSubdirectories = false;
m_watcher.Path = "C:\\MyEwatchedFolder";
m_watcher.NotifyFilter = NotifyFilters.LastWrite;
m_watcher.Changed += new FileSystemEventHandler(watcher_Changed);
m_watcher.EndInit();
m_watcher.EnableRaisingEvents = true;
}
void watcher_Changed(object sender, FileSystemEventArgs e)
{
FileSystemWatcher watcher = sender as FileSystemWatcher;
if (e.ChangeType == WatcherChangeTypes.Changed)
{
MessageBox.Show(string.Format("File!\n\n{0}", e.FullPath));
}
}
The Changed handler is getting called twice. I've looked all over googkle and can't find a reason or a way to fix it.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Have to tried increasing the FSW's InternalBufferSize?? It must be a multiple of the O/S page size(?? I think!). Default is 8KB. Keep in mind that each event that is internally queued needs 16 + (2 * filename length) bytes to store, so if you're encountering long filenames, you could overflow the buffer and not know anything about it.
|
|
|
|
|
The file names are approximately 30 characters long, but I'm only throwing one at a time at the application as a test, so I don't think the buffer would be filling up, even at the default 8k size.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
|
AFAIK FileSystemWatcher makes only a best attempt at signaling file system actions; it does not guarantee to report everything, and I expect it to report more actions per file than you care to receive, e.g. writing a file changes the content (once or more) and changes the metadata (such as last write time); the file system itself only guarantees metadata once the file got closed, but AFAIK may or may not update things in between. So you really have to defend yourself against multiple reports.
|
|
|
|
|
I set up a list of recently "handled" filenames, and if the name is in the list, I don't do anything. If it's not in the list I add it. If the list grows beyond a certain threshold, I delete the first item in the list. It's a kludge but it appears to work fine since I'm not expecting more than a couple of files at a time.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
OK
FWIW you could turn it into an MRU list by:
first removing the new item, if that fails and list filled to capacity removeAt(0);
then always add the new item.
|
|
|
|
|
I've run into this also with the change event. As I recall it is accurate because file systems generates multiple actions when a file is changed. I was able to get around it with this bit of clugyness
void Watcher_Changed(object sender, FileSystemEventArgs e)<br />
{<br />
Watcher.EnableRaisingEvents = false;<br />
Watcher.Changed -= new FileSystemEventHandler(Watcher_Changed);<br />
<br />
<br />
Watcher.Changed += new FileSystemEventHandler(Watcher_Changed);<br />
Watcher.EnableRaisingEvents = true;<br />
}
only two letters away from being an asset
|
|
|
|
|
Hello,
This is normal, what you see as one logical operation actually involves two different physical operations that throw this event. I've learnt that a few years ago, I just can't remember what were the physical operations exactly but it made sense. Something already occurs when the file gets opened or when the write operation is not yet flushed, but the fact is that you can actually detect that. A the first event, the file size is not yet correct: in the case of a new file, the size will be zero, and for modifications... well you have to know the previous size
Below is a sample of something I wrote a few years ago, please forgive me I wrote it in VB and I am not particularly proud of this piece of code Here, I had the advantage that I was monitoring one file, so I kept remembering its size.
I remember there is a more elegant solution in the source code of Log4Net, the popular open source logging framework. They use a file system watcher to watch their own config file for changes. If I remember well, they make use of timer or something like that, the technique works always and you always get only 1 event.
Sorry it is late for me, but you should look at this source code, it contains your answer
JC
Private _ChangeWatcher As FileSystemWatcher
Private Sub InitWatcher()
_ChangeWatcher = New System.IO.FileSystemWatcher()
AddHandler _ChangeWatcher.Changed, AddressOf Watcher_Changed
With _ChangeWatcher
.BeginInit()
.EnableRaisingEvents = True
.IncludeSubdirectories = False
.NotifyFilter = IO.NotifyFilters.LastWrite
.Path = _FolderToMonitor
.Filter = _FileName
.EndInit()
End With
End Sub
''' -----------------------------------------------------------------------------
''' <summary>
''' Called when the FileSystemWatcher detects a change (matching
''' the NotifyFilter) on the specified file. In this case, the handler
''' will be called when a file is created or updated.
''' </summary>
''' <remarks>
''' We cannot rely on the ChangeType, it is always CHANGED,
''' even when the file was created. Luckily, it has no impact.
''' </remarks>
''' -----------------------------------------------------------------------------
Private Sub Watcher_Changed(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs)
SyncLock Me
If String.Compare(e.Name, _FileName, True, CultureInfo.InvariantCulture).Equals(0) Then
If e.ChangeType.Equals(WatcherChangeTypes.Changed) OrElse e.ChangeType.Equals(WatcherChangeTypes.Created) Then
Dim _FileInfo As New FileInfo(e.FullPath)
If _FileInfo.Exists Then
' Avoid multiple notifications for the same event.
If Not _FileInfo.Length.Equals(_PreviousFileSize) Then
_PreviousFileSize = _FileInfo.Length
InitiateLoad()
End If
End If
End If
End If
End SyncLock
End Sub
Jean-Christophe Grégoire
|
|
|
|
|
Imagine a class with the following properties
Shape //differnt shapes
Colour //different colours
Fill //yes or no
Border //yes or no
Etc etc – there could lots of different ones, maybe even a 100
Each value associated with the above properties has to have a key/value pair (eg [1] [Red]), the number will be used to submit to a 3rd party software and the text to give the option to the user.
Now how should I store them?
I could use a hashtable to store the options as DictonaryPairs, and then the data type of each property could be a DictonaryPair. This works in theory, but in practice it means the fill could be given [1] [Red] instead on [0] [No]
So I then thought I could inherit from DictonaryPair to make
ShapeDictonaryPair
ColourDictonaryPair
BoolDictonaryPair
And then the data types could be the following
ShapeDictonaryPair Shape
ColourDictonaryPair Colour
BoolDictonaryPair Fill
BoolDictonaryPair Border
Which would work, but I will end up with loads of different Pair classes, which I think I will have to.
So then, would you use Hashtables or generic lists? The items in the list or hashtable will need to end up in combo boxes, with the user seeing the value and then store the pair
Or any other ideas
Did that make sense
|
|
|
|
|
You don't really need to create that many pairs - use the generic KeyValuePair and Dictionary classes instead.
like
Dictionary <int, Color > dict = new Dictionary <int, Color >
dict.Add(1, Color.Red);
dict.Add(2, Fill.All);
|
|
|
|
|
Looks good, but it wont work for my needs (my fault for not being detailed enough in the first post, sorry)
The value must be a string, so they will all be
Dictionary <int, string >
The 1st post was only trying to give an example, and in the real app, the values will be things that are not represented by .net classes (I could make classes for each type, but again that means loads of classes)
|
|
|
|
|
I really have searched for this solution online and haven't found it. I want to do be able to get the increment value that the access DB has created. Now I know I should be using a scalar query and I should be using something called @@identity. How it will all come together in my code is what I really can't seem to figure out.
|
|
|
|
|
Simply try
SELECT @@IDENTITY
with a SqlCommand and ExecuteScalar method.
|
|
|
|
|
will it be "SELECT @@identity FROM tableName"?
|
|
|
|
|
|
SELECT @@identity
This is typically done at the end of an INSERT to the database, where the database returns the identity of the new row, normally from a stored procedure. You cannot use it any time you want in an attempt to get the id of the last record. The concept just doesn't work that way. For example, what if you had two clients execute that statement on the database at the same time?
You can read up more on it here[^]. Keep in mind, that you're going to have to also read up on what an SQL Session and Scope are to fully understand the material.
|
|
|
|
|
I am writing an application that will give me content of a web page.
I wrote following code for that.
WebRequest objRequest = HttpWebRequest.Create("url");
StreamReader sr = new StreamReader(objRequest.GetResponse().GetResponseStream());
string result = sr.ReadToEnd();
sr.Close();
This works fine if the url i am connecting to does not require to login.
I want to read content of a web page which requires first to put in login details (user/password) to get access.
for that i tried with
WebRequest objRequest = HttpWebRequest.Create("url");
NetworkCredential netCred = new NetworkCredential("User","Password");
objRequest.Credentials = netCred;
StreamReader sr = new StreamReader(objRequest.GetResponse().GetResponseStream());
string result = sr.ReadToEnd();
sr.Close();
No success with this as well. It gets the contents of log in page and not the one specified by url.
Can anyone help me with this?
How to Read contents of a webpage which requires to login first.
Thanks,
AksharRoop
|
|
|
|
|
AksharRoop wrote: I want to read content of a web page which requires first to put in login details
Do you log in through a web page, or does your browser display a login dialog for you?
If you use forms based login (i.e. through a web page) then you will have to find a way to replicate that as if the user was actually sitting at the browser.
|
|
|
|