|
Wow! Nice idea!
This is not as easy as a C++ global variable(I still need to identify owner: MyForm1.A.globalVar ), but this is a clever solution to the lack of global variables. Got my 5! Thanks.
A suggestion, make class A sealed.
//This is not a signature
while (I'm_alive) {
cout<<"I Love Programming";
}
|
|
|
|
|
Hamed Mosavi wrote: This is not as easy as a C++ global variable
It's a bit more verbous than using global variables, but verbosity is not bad in itself.
The advantages over global variables is that it's easy to locate the variable as the code says exactly where to look, and that there is no risk of name conflicts with other modules that also uses global variables.
Hamed Mosavi wrote: I still need to identify owner: MyForm1.A.globalVar
Put the class outside the form (perhaps in a class file by itself), then you only have to specify the name of the class: A.globalvar .
Hamed Mosavi wrote: A suggestion, make class A sealed.
Even better, make the class static. Then you can't put non-static members in it by mistake, and it's automatically sealed. Also it's obvious how the class is supposed to be used.
---
single minded; short sighted; long gone;
|
|
|
|
|
What I have done is created an AppSettings class which has many public properties - example:
sealed class AppSettings
{
static string appDir;
public static string AppDirectory
{
get
{
if (appDir != null)
return appDir;
appDir = (code to get app dir);
return appDir;
}
}
}
And then I can use it from anywhere in the application.
Mike
|
|
|
|
|
Mike_V wrote: What I have done is created an AppSettings class which has many public properties
I was thinking just about the same technic;)
//This is not a signature
while (I'm_alive) {
cout<<"I Love Programming";
}
|
|
|
|
|
Mike_V wrote: created an AppSettings class
You mean like what is already available by using app.config?
only two letters away from being an asset
|
|
|
|
|
Not quite... otherwise I would have used app.config
|
|
|
|
|
Hamed Mosavi wrote: In C#, however, I've read that there is not any global variable because it shows a poor design, instead we shall use app.config file.
Correct.
Hamed Mosavi wrote: Is it possible to add/retrieve a variable to this file at RUN TIME?
If this is needed in your design then you may be better off considering a datastore, such as SQL Server Express or Compact Edition, both are free, lightweight and easily coded against. It would also allow for a easier upgrade path from your application, or to a full SQL Server implementation if necessary.
only two letters away from being an asset
|
|
|
|
|
Hi,
Is it possible to send a certificate chain to the client from a server SslStream during handshakes? I need to be able to do this, but SslStream doesnt' seem to support it...
however, during client validation, the calllback DOES have a X509Chain argument, is the chain support only one-way?
Thanks
|
|
|
|
|
Im coding a virtual hair styling and makeover tool. Can any buddy know any link or idea abt virtual makeover.... Any link for the help.......
actually when I apply makeover it should blend the applied color on the skin. How can I get the blended effect?? Wht function I should use on the pixel previos color and the new color to be applied........ ANY Idea?????
|
|
|
|
|
I have a form with a complex graph drawn on it. As the graph does not fit the available area on the form, scrollbars need to be used for navigating around the graph.
I am thinking of an "atlas" or "navigation" control, something similar to the one we see in Google maps, when we hover the cursor over the small navigation pane, the cursor changes to a highlighted square, clicking on the pane and moving the cursor around pans the map in the main view.
If anyone is aware of such a control, it will be great if you can please share the link.
Thanks for your attention.
indy
|
|
|
|
|
Hello everyone,
I just try to add panels in my windows form and then add some textbox to these newly added panels. Unfortunately, while the panels seems ok the textboxes do not appear!
I try the BringToFront() method but this doesn't work too. What can the problem be?
Thanks.
.:: Something is Wrong ::.
|
|
|
|
|
Seeing some code would help us to help you...
|
|
|
|
|
I add the panels dynamically with :
<br />
Panel p = new Panel();<br />
p.Location = new Point(3, panel1.Controls[panel1.Controls.Count - 1].Location.Y + 28);<br />
p.Size = new Size(262, 26);<br />
p.BackColor = Color.Blue;<br />
panel1.Controls.Add(p);<br />
The panels are added to panel1 with no problem. Everything is ok. Then I try to add 3 textboxes to the last panel.
<br />
.....<br />
for (int i = 0; i < 3; i++)<br />
{<br />
TextBox t = new TextBox();<br />
addTEv(i, t);<br />
}<br />
<br />
<br />
<br />
}<br />
<br />
private void addTEv(int i, TextBox t)<br />
{<br />
if (i == 0)<br />
t.Location = new Point(3, panel1.Controls[panel1.Controls.Count - 1].Location.Y);<br />
else if (i == 1)<br />
t.Location = new Point(93, panel1.Controls[panel1.Controls.Count - 1].Location.Y);<br />
else<br />
t.Location = new Point(183, panel1.Controls[panel1.Controls.Count - 1].Location.Y);<br />
<br />
t.Size = new Size(75, 20);<br />
t.BorderStyle = BorderStyle.FixedSingle;<br />
t.BackColor = Color.White; <br />
panel1.Controls[panel1.Controls.Count - 1].Controls.Add(t);<br />
}<br />
Thanks.
.:: Something is Wrong ::.
|
|
|
|
|
Hi,
two remarks:
- a control's location is relative to the object that contains that control,
so t.Location = new Point(...Location.Y);
is not correct; try replacing most of addTEv by the line:
t.Location = new Point(90*i+3, 20);
- you may have to call panel1.Invalidate() to make the UI redraw everything
|
|
|
|
|
pashje wrote: for (int i = 0; i < 3; i++)
{
TextBox t = new TextBox();
t.Visible = true ;
addTEv(i, t);
}
|
|
|
|
|
Hi all. I'm trying to use the paintdesktop api call in a c# application. I'm using the following code in the paint event of the form, but this causes a lot of flickering when it draws.
Graphics g = this.CreateGraphics();
IntPtr hdc = g.GetHdc();
PaintDesktop(hdc);
g.ReleaseHdc();
g.DrawImage(Interface, 0, 0);
g.Dispose();
I presume that I need to use some form of backbuffering to stop this flickering, however trying to draw the wallpaper with paintdesktop to a system.drawing.bitmap fails. I *think* I would be able to draw it to a bitmap created with the api createbitmap, but don't really know how to use this call or then get a HDC to such a bitmap and haven't been able to find any simple instructions for .net.
Can anyone provide a sample or a link to an *easy* article which explains it, or suggest another way reduce the flickering? Or does anyone have any experience with or links to articles about paintdesktop with .net that they could share?
Thanks!
|
|
|
|
|
Hi,
I Created an application that allows user to draw shapes, pictures,... I had also flickering problem and a single line of code resolved my problem. Try this line in the Initilization of ure Control/Form :
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
Change the first argument to ure needs.
HTH.
Hayder Marzouk
|
|
|
|
|
Thanks for the suggestion, but using that line causes just the form to be blank - from what I can gather paindesktop doesn't support double-buffering in that way
|
|
|
|
|
I just realized that unicode characters are normally represented in ConsoleBuffer if I set the Font to Lucida Console. So, how to change the font?
|
|
|
|
|
Hi,
To change the font :
- right click on the console title bar
- select properties
- Select the Font Panel and change the font.
HTH.
Hayder Marzouk
|
|
|
|
|
Yeah. I know how to do it manually, but how to change the font programmatically?
|
|
|
|
|
Hi all,
I have a question would like to ask regards to the complex data binding using checkbox control. My situation was my data types at SQL database was char data types and it holds only 'Y' and 'N' value. Now I would like to bind the char datatypes 'Y'/'N' to the checkbox control. When the values hold for 'Y' and checkbox will be checked. Otherwise, it was in uncheck mode. If the values holds for other data values beside 'Y' / 'N', an intermediate checkbox value will be holded. whatever method being tried before, it can't bind correctly onto the checkbox control, is there any method I can bind it correctly using char data types by using checkbox control?
Steven Leong
|
|
|
|
|
Hi,
This can be resolved using Format/Parse handlers. Here the code :
<br />
Binding YesNoBinding = new Binding("Checked", yourDatasource, "YourPropertyName", false, DataSourceUpdateMode.OnPropertyChanged);<br />
YesNoBinding.Format += new ConvertEventHandler(YesNoBinding_Format);<br />
YesNoBinding.Parse += new ConvertEventHandler(YesNoBinding_Parse);<br />
yourCheckBox.DataBindings.Add(YesNoBinding);<br />
And here the code for handlers :
<br />
void YesNoBinding_Parse(object sender, ConvertEventArgs e)<br />
{<br />
if ((bool)e.Value == true)<br />
e.Value = "Y";<br />
else<br />
e.Value = "N";<br />
}<br />
<br />
void YesNoBinding_Format(object sender, ConvertEventArgs e)<br />
{<br />
if ((string) e.Value == "Y")<br />
e.Value = true;<br />
else<br />
e.Value = false;<br />
<br />
}<br />
HTH.
Hayder Marzouk
|
|
|
|
|
I need to write some com server with C# language - how can i do it ?
|
|
|
|
|