|
Hi,
The Idea:- If I Have 25 Forms and I want To put Eact Five Forms In One Form In The Tab Control And It's Not Allowed To Make Nested Forms, So I Will Use The User Control Instad Of Forms. Now I Want To Convert This Forms To User Control By Easy Way.
The Solution: change the base class From Form To User Control I think this is agood idea since "UserControl also has the same inheritance tree" but I don't know if i will face probems? but i will try
Thanks.
|
|
|
|
|
Try changing the .TopLevel property (it's hidden so it won't show up in Intellisense!) of your child forms to False, the you can set it's .Parent property to any object that derives from the Control class, like a TabPage.
Dim myForm As New Form3
myForm.TopLevel = False
myForm.Parent = TabPage1
myForm.Show()
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
sallam
i whant to make a c code(function)
which change the pc to aderess its mean we do any work that is perform on aderess via i print any thing
i whant that print on aderress screen
|
|
|
|
|
Your post didn't make ANY sense what-so-ever. We have no idea what you're talking about or what you want to do.
Perhaps someone who understands English better could post your question for you?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Is it possible to implement BorderLayout,Flowlayout and Gridlayout using C#
|
|
|
|
|
|
This is the INSERT command i call to try and insert a new record into the MS SQL Table. There is another value "t_id" used for the ID, but it is set to auto increment in the database.
When i run this code i get this error:
Line 1: Incorrect syntax near '?'. <br />
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br />
<br />
Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '?'.<br />
<br />
Source Error: <br />
<br />
<br />
Line 178: <br />
Line 179: insCon.Open();<br />
Line 180: insCmd.ExecuteNonQuery();<br />
Line 181: insCon.Close();<br />
Line 182: <br />
public void AddTicket_Click(Object Src, EventArgs E){ <br />
<br />
string insSql = "INSERT INTO MCI_Tickets (t_date, t_num, t_circuitID, t_ter, t_sc, t_cu, t_loc, t_info) Values (?, ?, ?, ?, ?, ?, ?, ?)";<br />
SqlConnection insCon = new SqlConnection(Conn);<br />
SqlCommand insCmd = new SqlCommand(insSql, insCon);<br />
<br />
insCmd.Parameters.Add(new SqlParameter("@t_date", SqlDbType.DateTime, 8));<br />
insCmd.Parameters["@t_date"].Value = tDate.Text;<br />
insCmd.Parameters.Add(new SqlParameter("@t_num", SqlDbType.Char, 5));<br />
insCmd.Parameters["@t_num"].Value = tNum.Text;<br />
insCmd.Parameters.Add(new SqlParameter("@t_circuitID", SqlDbType.Char, 15));<br />
insCmd.Parameters["@t_circuitID"].Value = tCir.Text;<br />
insCmd.Parameters.Add(new SqlParameter("@t_ter", SqlDbType.Char, 5));<br />
insCmd.Parameters["@t_ter"].Value = tTer.SelectedValue;<br />
insCmd.Parameters.Add(new SqlParameter("@t_sc", SqlDbType.Char, 6));<br />
insCmd.Parameters["@t_sc"].Value = tSc.SelectedValue;<br />
insCmd.Parameters.Add(new SqlParameter("@t_cu", SqlDbType.Char, 6));<br />
insCmd.Parameters["@t_cu"].Value = tCu.SelectedValue;<br />
insCmd.Parameters.Add(new SqlParameter("@t_loc", SqlDbType.NVarChar, 50));<br />
insCmd.Parameters["@t_loc"].Value = tLoc.SelectedValue;<br />
insCmd.Parameters.Add(new SqlParameter("@t_info", SqlDbType.NVarChar, 50));<br />
insCmd.Parameters["@t_info"].Value = tInfo.Text;<br />
<br />
insCon.Open();<br />
insCmd.ExecuteNonQuery();<br />
insCon.Close();<br />
<br />
DoConnect();<br />
pnlAdd.Visible = false;<br />
}
Thanks, Any help would be appreciated
|
|
|
|
|
Hello gurus,
I'd like to know how I can add a scroll bar in a UserControl ?
The generated graphic is too big to fit to the size of the control, so I wish to scroll the content of the control.
Thanks for giving me a code snipet to solve this.
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
|
i have this code:
string a, b="test";
a=b.charAt(2);
but when i try to compile, i get this error:
'string' does not contain a defination for 'charAt'(CS0117)
what seems to be the problem?
|
|
|
|
|
The problem is that there is no charAt method on the string object (I think it's JavaScript having that method).
char a;
string b = "test";
a = b[2];
Should do the trick.
|
|
|
|
|
now i've this
string repRec,repAddr;
repRec=rec.ToString();
this.repAddr=repRec[2];
the compilation returns me an error of:
Cannot implicitly convert type 'char' to 'string'(CS0029)
|
|
|
|
|
You need to have a look at the basic types of C#. A char is a single character and it simply isn't the same type as a string. If you look at my sample code you would se that I was declaring a char - so not a string - to receive the value.
So this should work:
string repRec;<br />
char repAddr;<br />
<br />
repRec=rec.ToString();<br />
this.repAddr=repRec[2];
Notice that rec.ToString() is a bit scary - it is not strongly typed. I would recommend a real cast of possible (or access to string members - whatever), then you get an error if it does not make sense. You might be used to loose type checks from JavaScript and find the strict checks of C# annoying... just wait until you are used to them, then you will hate the loose typechecks as they give way too many errors.
|
|
|
|
|
It might help to read and understand the error message the compiler gives you - usually it's right.
With the error message and error number given it's really easy to find the error and its description on MSDN, for example, so you can understand what went wrong.
That's something you'll have to learn because it's a lot easier and faster than asking why a trivial error occurred on CP...
Regards,
mav
|
|
|
|
|
Hello, i use theese few lines of codes to open different windows, form different places, but it seems not so object oriented, could somebody tell me a nicer way to do it, that would be easier to maintain also?
public void openWindow(System.Windows.Forms.Form parentForm, String childForm, String layout)
{
switch (childForm)
{
case "frmAsiakkaat":
frmPink pink = new frmPink();
pink.MdiParent = parentForm;
pink.Show();
break;
case "frmKohteet":
frmGold gold = new frmGold();
gold.MdiParent = parentForm;
gold.Show();
break;
case "frmRaportit":
frmBlue blue = new frmBlue();
blue.MdiParent = parentForm;
blue.Show();
break;
case "frmTervetuloa":
frmGreen green = new frmGreen();
green.MdiParent = parentForm;
green.Show();
break;
}
}
R
John
|
|
|
|
|
|
Thx, that took care of a few lines of worthless code!
|
|
|
|
|
|
Hi im new at these forums, so this is my first post, i hope that some of you guys could help me out with this problem i have.
I'm building a drag n' drop program that will allow a user to drag n drop an item (like a button) from one control to another.
Currently i have a problem managing threads, or rather parsing data between them.
My problem is this. I need to sample the mouse's x and y coordinates for each control so that it will drop the item at the correct place in the control. The reason im using threading is that once i start dragging an object (button) the sampling of the x and y coordinates pauses. Thus i need to run it in another thread.
My problem is that i can't seem to get _GetLocalMouseCoordinates to run in a thread of its own, i get this error
C:\Documents and Settings\My Documents\Visual Studio Projects\DragNDrop\DragDrop.cs(359): Method 'DragNDrop.Form1._GetLocalMouseCoordinates(object, System.Windows.Forms.MouseEventArgs)' does not match delegate 'void System.Threading.ThreadStart()'
The code is below, i have only pasted the "vital" part though. I hope that someone cna help. Thanks alot in advance!
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
namespace DragNDrop
{
///
/// Summary description for Form1.
///
/// Huske/tænke liste
///
/// 1. Threading hvor hurtig opdaterings tid kan formen klare uden at choke?
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel pnlDrag;
private System.Windows.Forms.Panel pnlDrop;
private System.Windows.Forms.Label lblDrag;
private System.Windows.Forms.Label lblDrop;
private System.Windows.Forms.Button btnDrag;
private System.Windows.Forms.Button btnPush;
private System.Windows.Forms.StatusBar statusBarGlobal;
private System.Windows.Forms.StatusBar statusBarLocalDrop;
private System.Windows.Forms.StatusBar statusBarLocalDrag;
// My generated variables etc.
public int iXCoorDrag;
public int iYCoorDrag;
public int iXCoorDrop;
public int iYCoorDrop;
public int iXCoorGlobal;
public int iYCoorGlobal;
public Thread GlobalMouseThread;
public Thread LocalMouseThread;
public bool bStopthread;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
public void pnlDrag_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
// GetGlobalMouseCoordinates();
statusBarLocalDrag.Text = "DRAG - Local X: " + e.X.ToString() + " Y: " + e.Y.ToString();
iXCoorDrag = Convert.ToInt32(e.X.ToString());
iYCoorDrag = Convert.ToInt32(e.Y.ToString());
}
private void pnlDrop_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
// GetGlobalMouseCoordinates();
statusBarLocalDrop.Text = "DROP - Local X: " + e.X.ToString() + " Y: " + e.Y.ToString();
iXCoorDrop = Convert.ToInt32(e.X.ToString());
iYCoorDrop = Convert.ToInt32(e.Y.ToString());
}
private void btnDrag_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
// GetGlobalMouseCoordinates();
}
private void btnPush_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
// GetGlobalMouseCoordinates();
}
private void btnDrag_Click(object sender, System.EventArgs e)
{
}
private void btnPush_Click(object sender, System.EventArgs e)
{
Button btnClick = new System.Windows.Forms.Button();
btnClick.Location = new System.Drawing.Point(0, 0);
btnClick.Name = "btnClick";
btnClick.TabIndex = 1;
btnClick.Width = 100;
btnClick.Height = 50;
btnClick.Text = "BUTTON CLICKED";
btnClick.Visible = true;
pnlDrop.Controls.Add(btnClick);
}
private void btnDrag_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Right) return;
if (e.Button == MouseButtons.Middle) return;
}
private void btnDrag_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
btnDrag.Location = new System.Drawing.Point(iXCoorDrag, iYCoorDrag);
MessageBox.Show("Moved to: " + iXCoorDrag + ", " + iYCoorDrag);
}
private void pnlDrag_DragLeave(object sender, System.EventArgs e)
{
}
private void pnlDrop_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
MessageBox.Show("DRAG ENTER");
}
private void pnlDrop_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
}
private void GetGlobalMouseCoordinates()
{
statusBarGlobal.Text = "Global X: " + Form1.MousePosition.X.ToString() + " Y: " + Form1.MousePosition.Y.ToString();
iXCoorGlobal = Form1.MousePosition.X;
iYCoorGlobal = Form1.MousePosition.Y;
}
private void _GetGlobalMouseCoordinates()
{
bStopthread = true;
while(bStopthread)
{
GetGlobalMouseCoordinates();
Thread.Sleep(100);
}
}
private void _GetLocalMouseCoordinates(object sender, System.Windows.Forms.MouseEventArgs e)
{
bStopthread = true;
while(bStopthread)
{
statusBarLocalDrag.Text = "DRAG - Local X: " + e.X.ToString() + " Y: " + e.Y.ToString();
iXCoorDrag = Convert.ToInt32(e.X.ToString());
iYCoorDrag = Convert.ToInt32(e.Y.ToString());
Thread.Sleep(100);
}
}
public void Form1_Load(object sender, System.EventArgs e)
{
ThreadStart myGlobalStarter = new ThreadStart(this._GetGlobalMouseCoordinates);
GlobalMouseThread = new Thread(myGlobalStarter);
GlobalMouseThread.Start();
ThreadStart myLocalStarter = new ThreadStart(this._GetLocalMouseCoordinates);
LocalMouseThread = new Thread(myLocalStarter);
LocalMouseThread.Start();
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
try
{
bStopthread = false;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
|
|
|
|
|
eclipsedk wrote:
C:\Documents and Settings\My Documents\Visual Studio Projects\DragNDrop\DragDrop.cs(359): Method 'DragNDrop.Form1._GetLocalMouseCoordinates(object, System.Windows.Forms.MouseEventArgs)' does not match delegate 'void System.Threading.ThreadStart()'
Ahhh, a more decriptive error there could not be. I can't judge the rightness of your overall algorithm, but the problem here is that you're trying to start a method that does not match the parameter list and return value specified by the ThreadStart delegate http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemthreadingthreadstartclasstopic.asp[^].
You can only start methods using that delegate that return void and accept no parameters. _GetGlobalMouseCoordinates matches the delegate. _getLocalMouseCoordinates on the other hand, wants an object and a MouseEventArgs .
Share and enjoy.
Sean
|
|
|
|
|
Hi,
Does anyone know how to identify .NET dll from others (such as COM dll).
Thanks.
|
|
|
|
|
Check the imports section to see if the dll mscoree.dll is included?
|
|
|
|
|
Sorry, I don't really get it.
What I meant was, is there any attribute we can check using Reflection to determine if a dll is a .NET dll.
Thanks.
|
|
|
|
|
When reflection works on the dll, you can be sure it is a .NET dll.
|
|
|
|
|
|