|
I'm developing this app that allows users to add controls that represent tasks by clicking a button. When the button gets clicked, a new TaskControl is created and added to the TaskPanel container.
The TaskControl has a DockStyle.Top. However, when the button gets clicked again to add another TaskControl, the new TaskControl gets added to the TaskPanel above the existing TaskControl(s). I want it to appear below the already existing controls.
How do I go about doing that?
|
|
|
|
|
Try calling .BringToFront() on the control you want at the top. Docking orders depend on the Z order of the controls. Play around with the BringToFront and SendToBack methods.
#include "witty_sig.h"
|
|
|
|
|
They are already displayed "on top", but the problem is that new controls push the old ones down (not on the z-axis, but on the y-axis). So I see 'em all, but like so (crude lineart )
------------------------------------
| container | <-- new one gets inserted here and pushes existing down
| -------------------------------- |
| | control | |
| | | |
| -------------------------------- |
------------------------------------
|
|
|
|
|
//Ok your requirement is to add your task control just beneth to the existing task control when //you click the add button.
//for eg : if this is your location value of panel control
this.yourpannel_control.Location=new System.Drawing.Point(8,0);
//then
//assign to public variable LocX and LocY (forgetting x and y co-ordinates values)
//initial values of LocX and LocY
this.LocX=yourpannel_control.Location.X;
this.LocY=yourpannel_control.Location.Y+32;
//(i gave 32 . you can give any number. based on this value your task control will add from top)
buttion_click()
{
if(_UCtl1==null)
{
_UCtl1=new yourtask_control()
this._UCtl1.Location = new System.Drawing.Point(LocX, LocY);
this.yourpannel_control.Controls.Add(_UCtl1);
}
else
{
_UCtl1=new new yourtask_control()
this._UCtl1.Location = new System.Drawing.Point(LocX, LocY);
this.yourpannel_control.Controls.Add(_UCtl1);
}
LocX=LocX;
LocY=LocY+32;
yourpannel_control.Height=LocY+16;
//(i gave 16. you can give the height of your task control + difference between two task control)
}
this code will add your task control just one beneth the other.
|
|
|
|
|
I want to write an if statement that will write the word "error" on a label when the backcolor of a certian textbox is yellow. This is what I tried.
if (textBox1.BackColor = Color.White)
{
label1.Text = "yellow";
}
When I tried this I got a error that said
" Cannot implicity convert type 'System.Drawing.Color' to Bool"
What do I need to do to make this work?
Can I do this?
|
|
|
|
|
Use "==" and not "=" when doing comparisons.
"=" is for assignments and "==" is the equality check.
Cheers,
Simon
sig :: "Don't try to be like Jackie. There is only one Jackie.... Study computers instead.", Jackie Chan on career choices.
article :: animation mechanics in SVG blog:: brokenkeyboards "It'll be a cold day in Hell when I do VB.NET...", Chris Maunder
|
|
|
|
|
It might be handy to purchase a book that goes into the basics of C#. These questions get answered in the the first 3 chapters of any book on C#.
|
|
|
|
|
|
//for demonstrating this eg. i am using a button,label and a textbox.
//use below mentioned code block inclick event of your button.
//showing color dialogbox
ColorDialog clr=new ColorDialog();
clr.ShowDialog();
//assign selected color
textBox1.BackColor= clr.Color;
//checking color and assigning label.text property
if(textBox1.BackColor==Color.White)
label1.Text="White";
else if(textBox1.BackColor==Color.Yellow)
label1.Text="error";
else
label1.Text="something else";
this is a small idea and you have to apply this based on your requirement.
Sreejith S S Nair
|
|
|
|
|
hi!
i have a .chm file, how can i link this file to menuitem "help" in program so that when some one click the help menuitem, the help file will pop up
thanks...
|
|
|
|
|
See the Help.ShowHelp method documentation in the .NET Framework SDK. The Help class and other related classes like the HelpProvider natively work with HTML Help 1.x files (.chm files) in the .NET Framework. The SDK documentation also includes samples about how to use these classes and their members.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
How does one store a byte array inside a table in a dataset?
<br />
|xs:element name="tblLogin"|<br />
|xs:complexType|<br />
|xs:sequence|<br />
|xs:element name="Login" type="xs:string" minOccurs="0" /|<br />
|xs:element name="Password" type="xs:string" minOccurs="0" /|<br />
|/xs:sequence|<br />
|/xs:complexType|<br />
|/xs:element|<br />
|/code|<br />
<br />
what I'd like to do is to save an MD5 encrypted password in the corresponding field of tblLogin, so that it can be filtered somehow later.<br />
<br />
Is there any specific datatype used for this situation? The byte array cant be converted back to a string because some chars go of range from the used text encoding. Thank's for your attention,<br />
<br />
<br />
<br />
<br />
<br />
Best regards,<br />
Anfernius
|
|
|
|
|
Simple...Check out the Convert.ToBase64String() and Convert.FromBase64() methods. Converting a byte array to a Base64 string will allow you to use it just like any other string, including saving it to a text file like XML.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
MD5 blobs are typically stored as hex-encoded strings. It's rather simple. To encode, for example, do something like this:
private string ComputeMD5(string value)
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] buffer = Encoding.UTF8.GetBytes(value);
byte[] cipher = md5.ComputeHash(buffer);
StringBuilder sb = new StringBuilder(cipher.Length * 2);
for (int i=0; i<cipher.Length; i++)
sb.Append(cipher[i].ToString("x2"));
return sb.ToString();
} For other binary data, this is typically stored in base64-encoded text. You can use the methods on the Convert class (like Convert.ToBase64String or Convert.FromBase64String or a transform like ToBase64Transform or FromBase64Transform in the System.Security.Cryptography namespace if you want to base64-encode or decode data from a stream.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Heath,
I hate to say this, but you missed a '<' in your example code. Part of the 'for (int i=0;...' loop was eaten by the tag monster...
Is there anything you DON'T know?
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Hi all,
I am new in Visual C#.net. I want to declare a global veriable in my c# project. But i dont know how to declare it and how to access that veriable in other forms. its a desktop application.
And my second problem is how to find value from listview in visual C#. I have a listview in this there are many coloums and rows. there is textbox txtsearch. I want that whenever user type in that textbox the value is atomaticaly selected in the listview and it sort on the basis of selection.
If any one have solution for this then please reply as early as possible.
Thank You,
Hemant Mane
|
|
|
|
|
There is no such thing as "global variables" using C# and, IIRC, isn't allowed by the CLI (though you can define global functions, i.e. methods not defined by a class).
Instead, you can use static fields or properties (properties are recommended for added safety since you can check the value being assigned before setting it):
public sealed class Options
{
private Options() {}
private static int option1;
private static string option2;
public static int Option1
{
get { return option1; }
set
{
if (value < 0) throw new ArgumentException();
option1 = value;
}
}
public static string Option2
{
get { return option2; }
set
{
if (value == null) throw new ArgumentNullException();
option2 = value;
}
}
} To set and get these, you simply refer to the static member:
string option1 = Options.Option2;
Options.Option1 = 10; If you're new to C#, you should also read the Visual C# Language[^] documentation in the Visual Studio .NET product documentation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
what Stewart wrote is very good idea. Here i am giving one more little solution.If you want to use some values or variables like connection string and something else that you need entire phase of your application is simply stored in .config file.
.config file (app.config) is an xml file that you can add using Project > Add New Item menu. there choose xml file and rename it as app.config.
in that xml file file you can see somthing like this
<?xml version="1.0" encoding="utf-8" ?>
just add below mentioned code
<configuration>
<appSettings>
<add key="sourcename" value="YourDataSourceName" />
<add key="ConnectionString" value="your connection string " />
</appSettings>
<system.windows.forms jitDebugging="true" />
</configuration>
so finally you will get this much in your app.config file.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="sourcename" value="YourDataSourceName" />
<add key="ConnectionString" value="your connection string " />
</appSettings>
<system.windows.forms jitDebugging="true" />
</configuration>
If you notice the <appsettings> tag then you will find
<add key="sourcename" value="YourDataSourceName" /> here <add key> will give a friendly name to your required data or value. eg. ConnectionString
and <value> is the actual value that you want in your programm.
How you will apply this in your forms or .cs file
-------------------------------------------------------
if you want to access the .config values you have to add a namespace called
using System.Configuration;
retriving value from .config
string Requiredvariable=ConfigurationSettings.AppSettings["ConnectionString"].ToString();
now you can use Requiredvariable to create database connection. you don't want to give the lengthy connection string value again and again in all forms or .cds file. You can reuse the Requiredvariable.
|
|
|
|
|
Hi there ... I have a form with the Web browser control over it covering the whole form. I have a help provider too for the form but pressing F1 doesnt allow the help provider's help file to show . As i understand it, I need to use MSHTML and IDocShowUI interface and implement ShowHelp but all my efforts have failed. Can anyone send me the code to implement it in C#? You can contact me at fayazhsn@hotmail.com .... I need this asap!!
Thanks in advance!!
|
|
|
|
|
See Using MSHTML Advanced Hosting Interfaces[^] for an explanation of how to properly implement the IDocHostUIHandler . When the WebBrwoser control (AxWebBrowser as VS.NET and aximp.exe call it by default) has the focus, it's implementation is queried, which doesn't work like .NET controls would. The COM implementation is what is responding to events in this case.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello. thanks for your prompt reply. I already read that article and also the one which is a chapter from a book by Ted Faison. Ted explains that I need to create a mshtml object to use that. I dont know how to do that. The article you've mentioned also talks abt IDocHostUIHandler . I need info abt IDocHostShowUI & ShowHelp .... How can I show my custom help file (*.chm) when F1 is pressed?
|
|
|
|
|
You implement them and expose your implementation to MSHTML (rather, the aggregate WebBrowser control) the same way. The article I linked shows you how to build a typelib from which you can create an interop assembly. You must do that unless you want to create an RCW manually, which is entirely possible (that's how I typically do it when I need to interop with only a few unmanaged interfaces).
For more information on these interfaces, you should see the topic Programming and Reusing the Browser[^], specifically the section Advanced Hosting Reference[^].
Once you've created an RCW for the IDocHostShowUI interface, you must tell the WebBrowser control that you're it's parent. The article I linked also explains one way to do that. There are several ways, and without hacking the source for the AxWebBrowser control (if you use aximp.exe to create that interop assembly, you can opt to generate source code instead) that's the easiest way to do it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How can a open the *.sln file or *.csporj file made in Professional version of VS.NET with the Enterprise Architect.
Thank you
|
|
|
|
|
Same way you open any other solution or project file.
Especially since the solution was created in a lower level of VS.Net than what you're trying to open it in, there should be no problems.
Is it possible that the solution was created in .Net 1.1 and you're trying to open it with .Net 1.0? that would cause some minor difficulty. But Pro to Enterprise should be no problem at all.
Grim (aka Toby) MCDBA, MCSD, MCP+SB
|
|
|
|