|
Wow Ted, that just sounds horrible. But given your situation:
sysrev wrote: before I’ve had time to learn it
and
sysrev wrote: a group of 24 progress bar components
With that situation I would go with "if it works, I don't care".
|
|
|
|
|
But I'll need to do it again somewhere - and again, and again.........
Ted Edwards
|
|
|
|
|
Hi,
hard to give a good answer without knowing your exact situation. You could add all progress bars to a List<progressbar>. After you have done this once you can iterate the list with for/foreach or whatever technique you like.
Robert
|
|
|
|
|
Thanks for the suggestion Robert.
The progress bars display the output of a pressure sensor over a 24 hour period. When I get a new reading, I shift values chronologically "down" one bar and put the new value in the "top" (most recent) bar. The coding begs for an iterative loop but I don't know how to address the bars name property with the index. So I ended up using a switch construct which works okay but is awkward to maintain.
The List class is new to me and on your suggestion I had a quick look at it. I must say, it does not look promising but will try it out if I can.
Ted
|
|
|
|
|
Hi,
I'll try to outline what I meant:
private List<ProgressBar> _bars;
_bars = new List<ProgressBar>(new ProgressBar[] { pb1, pb2, pb3, ... });
for (int i = 0; i < 24; i++)
{
_bars[i] = someArrayWithTheValues[i];
}
With the mod operator you could also easily switch which hour should be displayed at the top:
int hourToDisplayAtTop = 4;
for (int i = 0; i < 24; i++)
{
_bars[i] = someArrayWithTheValues[(i + hourToDisplayAtTop) % 24];
}
Robert
|
|
|
|
|
I think I can see what you are suggesting and am trying to experiment with it in a new application as here:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace IndexComponents
{
public partial class Form1 : Form
{
private ProgressBar pb1;
private ProgressBar pb2;
private ProgressBar pb3;
private List<ProgressBar> _bars;
public Form1()
{
InitializeComponent();
int[] someArrayWithTheValues = new int[3] { 1, 2, 3 };
//Field declaration in the Form/UserCotrol
/// private List _bars;
//somewhere after the InitializeComponents call
/// _bars = new List(new ProgressBar[] { pb1, pb2, pb3 });//when you want to update the bars
_bars = new List<ProgressBar>(new ProgressBar[] { pb1, pb2, pb3 });//when you want to update the bars
for (int i = 0; i < 3; i++)
{
_bars[i] = someArrayWithTheValues[i];
}
//With the mod operator you could also easily switch which hour should be displayed at the top:
int hourToDisplayAtTop = 2;
for (int i = 0; i < 3; i++)
{
_bars[i] = someArrayWithTheValues[(i + hourToDisplayAtTop) % 24];
}
}
}
}
I am now working on the last two(I hope!) build error which are flagged within the two for loops as below:
Error 1 Cannot convert type 'int' to 'System.Windows.Forms.ProgressBar'
Error 2 Cannot implicitly convert type 'int' to 'System.Windows.Forms.ProgressBar'
Ted Edwards
|
|
|
|
|
Replace _bars[i] = ... with _bars[i].Value = ...
(Sorry, my mistake)
Robert
|
|
|
|
|
That's great. It all works - I can experiment further now I have a working example.
Thanks for your help.
Ted
|
|
|
|
|
PC Administrator, using my application, needs to select a folder in which any standard user could read and write. My application needs to verify for any selected folder whether a standard user can read-write into it. How do i do that?
Note that the folder is being set up by Administrator, so checking current read-write access is no good.
Free C++ libraries with source code on www.neatcpp.com: TWAIN, DirectShow, Interprocess Communications, etc...
|
|
|
|
|
|
You could impersonate a standard user and then attempt to read from/write to that folder, if they both work then you have the correct permissions.
|
|
|
|
|
I want to auto login a website(for example,gmail) from winform client.The realization is as follow.
SHDocVw.InternetExplorer IE = new InternetExplorer();
IE.Visible = true;
string URL = "http://www.gmail.com";
object nullArg = null;
IE.Navigate(URL, ref nullArg, ref nullArg, ref nullArg, ref nullArg);
Thread.Sleep(5000);
mshtml.IHTMLDocument2 DOM = (mshtml.IHTMLDocument2)IE.Document;
mshtml.IHTMLInputTextElement textBoxUserName = (mshtml.IHTMLInputTextElement)DOM.all.item("Email", null);
textBoxUserName.value = "****";
mshtml.IHTMLInputTextElement textBoxPassword = (mshtml.IHTMLInputTextElement)DOM.all.item("Passwd", null);
textBoxPassword.value = "****";
Thread.Sleep(3000);
mshtml.HTMLInputElement img = (mshtml.HTMLInputElement)DOM.all.item("signIn", 0);
img.click();
Thread.Sleep(5000);
I code it in vs .net 2005.It works on my machine.But it fails on the machine that only installs .NET 2.0 Framework.The error information is as follow:
System.InvalidCastException Message: Unable to cast COM object of type 'System.__ComObject' to
class type 'mshtml.HTMLDocumentClass'. COM components that enter the
CLR and do not support IProvideClassInfo or that do not have any
interop assembly registered will be wrapped in the __ComObject type.
Instances of this type cannot be cast to any other class; however they
can be cast to interfaces as long as the underlying COM component
supports QueryInterface calls for the IID of the interface.
How can I solve this problem?
|
|
|
|
|
|
Is there any way to get the Line Number of an Exception at runtime. I don't want to use the pdb Files in the release version. I also tried the Stackframe Object and it also doesn't work.
I know that the Project is in the IL when it is build. But perhaps there is a way with reflection?
Any Ideas? Please help me.
|
|
|
|
|
Michael Sterk wrote: Is there any way to get the Line Number of an Exception at runtime.
Yes, pdb files...
Michael Sterk wrote: I don't want to use the pdb Files in the release version.
Why?
Michael Sterk wrote: I know that the Project is in the IL when it is build. But perhaps there is a way with reflection?
No, there isn't. Line numbers, variable names, source file names - all gone. That is what pdb file is - mapping IL instruction adresses to source file lines.
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Aren't there any security issues when using pdb files?
And what is with ASP.NET Web Applications? Where do i get the pdb file for this? In the "Temporary ASP.NET Files" folder ?
|
|
|
|
|
Yes, there is a security problem. With a pdb file your application can be decompiled and used by a 5 year old scrip kiddie. Without the pdb file only script kiddies over the age of 7 can do it.
The PDB files should generally be found in the same folder as the DLL files - so the "bin" folder of your website.
|
|
|
|
|
Hi
I have a window service which is suppose to read a text file the text file is in a directory called templates. but when i install the window service the service is unable to read the text file and an error is thrown. In the set up of the window service i have included the text files in the template folder.
What could be the problem, Please help
Regards
|
|
|
|
|
Are you using relative paths?
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|
|
Thanks its resolved
Regards
|
|
|
|
|
Hello,
is there any way to intercept network traffic of a given program to manipulate and then continue sending the data to the "real" destination?
The programs "freecap" and "sockscap" do something like that, but sadly only support socks proxies.. and I need a much simpler thing anyway
If anything like that exists in the .NET Framework I'd love to get a pointer to related APIs.
Thanks in advance,
Prattel
|
|
|
|
|
prattel wrote: is there any way to intercept network traffic of a given program
Yes, it's called a proxy server. This application would have to connect to the database through the proxy.
prattel wrote: manipulate and then continue sending the data to the "real" destination?
It's possible, but hardly practical.
prattel wrote: The programs "freecap" and "sockscap" do something like that, but sadly only support socks proxies
They do packet capture using a driver inserted into the network stack. This is something that you can not write in C#.
prattel wrote: and I need a much simpler thing anyway
What you want to do is not simple on any level.
prattel wrote: If anything like that exists in the .NET Framework I'd love to get a pointer to related APIs.
There is nothing in the .NET BCL that can do what you want. This is a very specialized app you want and it's FAR from easy to write. If your application can use a proxy server, writing the proxy is about as easy as it's going to get, and that's by no means an easy application to write.
|
|
|
|
|
[quote]There is nothing in the .NET BCL that can do what you want. This is a very specialized app you want and it's FAR from easy to write. If your application can use a proxy server, writing the proxy is about as easy as it's going to get, and that's by no means an easy application to write.[/quote]
Writing the proxy was in fact the easier part, only a few loc. I can eG set it up to forward any incoming traffic on port x to google.com at port 80. My browser tells me it's working
I already guessed I'd need to write something at driver level.. makes me a sad panda :/ I guess the minimum aproach is a dll that hooks winsocks functions. Probably too much hassle.
Oh.. and sadly the program cannot use a proxy server, which is why I have to do it like that
Thanks for your response, cheers
Prattel
|
|
|
|
|
Hello,
I have an issue with a ComboBox control which I'll try to explain here.
On a windows form, I have Panel A. As a child control to Panel A I have another panel (Panel B). One of the children of Panel B is a ComboBox (ComboBox1).
- Panel A
- Panel B
- ComboBox1
The ComboBox1 is global to the form, since it's needed elsewhere on the code. If I set "ComboBox1.Parent = null" and then dispose of Panel B, the next time I create a new panel with our ComboBox1 inside, none of the ComboBox1 events will fire. Particularly, SelectedIndexChanged, DropDown, DropDownClosed.
It seems that because the parent of ComboBox1 was destroyed it somehow messes up some internal things inside ComboBox1.
Any ideas why this happens? Any suggestions to solve this? Is this a bug from Microsoft?
|
|
|
|
|
Hi,
if ComboBox1 is part of panelB, then there must be a panelB.Controls.Add(ComboBox1) somewhere.
if you want to remove panelB and reuse ComboBox1 elsewhere, say on panelC, then you must
execute a panelC.Controls.Add(ComboBox1).
Events get dispatched by the active form using its chain of Controls as it is set through
the Controls property. A Control that is not part of the Controls chain will not receive
events.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|