|
Tried it in VS2008, and you're right.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Nope: it doesn't work like that. When you select "Dock...Fill" the panel covers the entire client area, and will re-size itself to make sure it always does.
If you have multiple controls that are all set to Fill, then tehy are all teh same size, and stacked behind each other. The only way to see them at run time is to make three of them Visible=False and one of them Visible=True
At Design time, they are also stacked up, only you can't make them invisible. The only way I know to select a specific panel is to use the drop down list at the top of the Properties window. Even that won't let you select panel1 and drop controls on it if panel 2 is on top of it. To do that, you will have to select a panel, use the "send to back" button, select a different panel, "send to back" and repeat until you have the panel you wanted.
An easier (and nicer for the user) approach might be to use a TabControl instead, and put each of the panels on separate tabs.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Thanks for help i did a similar but i take 3 panels and set to dock: fill and I made sure that's not any one panel is child of the other panel... So i set all panels are on Form1. Then if i want to modify some panel i used Format -> Order -> Bring to front then i have access to a panel which i want to modify...
I also type those 3 panels on
visible = false
and
private void toolStripSplitButton2_ButtonClick(object sender, EventArgs e)
{
panel2.Visible = false;
panel3.Visible = false;
panel1.Visible = true;
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
panel2.Visible = true;
panel1.Visible = false;
panel3.Visible = false;
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
panel3.Visible = true;
panel1.Visible = false;
panel2.Visible = false;
}
so it's that good in code? Or should i some change?
|
|
|
|
|
It's clear enough! I would be tempted to have a generic routine which sets them all invisible and then set only the one I want visible though:
private void toolStripSplitButton2_ButtonClick(object sender, EventArgs e)
{
SetVisible(panel1);
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
SetVisible(panel2);
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
SetVisible(panel3);
}
private void SetVisible(Panel p)
{
panel1.Visible = false;
panel2.Visible = false;
panel3.Visible = false;
p.Visible = true;
}
For just three panels, I would be happy enough with that: to go any higher, I would use a loop instead:
private void SetVisible(Panel p)
{
foreach (Control c in Controls)
{
Panel pan = c as Panel;
if (pan != null)
{
pan.Visible = false;
}
}
p.Visible = true;
}
Oh, and I would get rid off your names! Don't use "panel1", "panel2", "tool_stripButton2" etc.: use names that describe what they contain. "panColors" and "panFonts", "tsbSelectColors" and "tsbSelectFonts" help the readability of your code a lot, and that makes it easier to debug and work with.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
ok i rename it all and put thise code :
private void toolStripSplitButton2_ButtonClick(object sender, EventArgs e)
{
SetVisible(panel1);
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
SetVisible(panel2);
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
SetVisible(panel3);
}
private void SetVisible(Panel p)
{
foreach (Control c in Controls)
{
Panel pan = c as Panel;
if (pan != null)
{
pan.Visible = false;
}
}
p.Visible = true;
}
it's more beauty of code... than set all false/true without the intended purpose if the panels will...
P.S It's really uncomfortable to switch between all panels "bring to front"
thx for help !!
|
|
|
|
|
nighttrain1 wrote: P.S It's really uncomfortable to switch between all panels "bring to front
Ain't that the truth! That's partly why I prefer the TabControl approach.
nighttrain1 wrote: thx for help
You're welcome!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
"hehe" thx again
|
|
|
|
|
If you want to add several controls(panels in your case) to the same form and Dock them all as Fill, below is the best solution:
- Add Custom user controls to your Project, each of them containing one of the panels.
- Add these controls to your form and dock them as Fill.
Now if you want to edit one of the panels, simply edit the custom user control you created 
|
|
|
|
|
hi all,
i use webBrowser control in windows form application, my problem is when i open the form and in the form_Load write code to put the bodyhtml value of the webBrowser it still not loaded and its be empty,
it means the form load finished before the webBrowser Control finish loading,,
how i can solve this problem, please help me.
thanks all
|
|
|
|
|
web browsers typically work in an asynchronous way as they need an undefined amount of time to fetch and render the requested page; the WebBrowser Control offers several events, including a DocumentCompleted one. For simple pages, that suffices. For more complex situations (frames, multiple images, ...) you will notice it fires more than once, and you need to add code to check WebBrowserDocumentCompletedEventArgs.Url to see what has been loaded, or insert some delay after the first DocumentCompleted to make it probable but not certain everything has finished loading.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi guys,
I create a formular in my .js file.I create a mysql databes with navicat 8 editor.I wanna that when i enter my data in the formular and click in the save button,it will be saved in the database.For that,in my .aspx.cs file i have this code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.Odbc;
public partial class application_Application : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
switch (this.Request ["Action"])
{
case "SaveData":
{
string nom = this.Request ["Name"];
string CIN = this.Request ["CarteIdentité"];
string Mat = this.Request ["Matricule"];
string ConnectionString= "Driver={MySQL ODBC 3.51 Driver};"
+ "Server=localhost;" + "Database="informations";" + " UID=root;" + "PASSWORD=root";
OdbcConnection conn=new OdbcConnection(ConnectionString);
string requete=??????
OdbcCommand ODC=new OdbcCommand(requete,conn);
OdbcDataReader ODR;
conn.Open();
ODR=ODC.ExecuteReader();
ODR.Close();
conn.Close();
}break;
default:{}break;
}
}
}
my problem is how i will write in "string requete= " to send the information to my database table
Ty for u help

|
|
|
|
|
Your query will be look like the following:
string requete="INSERT INTO TableName(Column1, Column2, column3)
VALUES('" + nom +"', '" + CIN + "', '" + Mat +"')";
and then finally
ODR=ODC.ExecuteNonQuery();
Hope this helps
|
|
|
|
|
Hi Umair,
I tried u solution.It runs me an error"informations doesn't exist in the current context",informations is the name of my database"
my mysqlconnexion string is:
string ConnectionString= "Driver={Navicat 8 for MySQL};"
+ "Server=localhost;" + "Database="+informations+";" + " UID=root;" + "PASSWORD=root";
Also the
ODR=ODC.ExecuteNonQuery(); u tell me to add,what is its utility?where can I place it?
ty
|
|
|
|
|
Umair Feroze is correct, but I would strongly recommend you use a parametrised query instead of adding the string together:
string requete="INSERT INTO TableName(Column1, Column2, column3) VALUES(@NOM, @CIN, @MAT)";
...
ODC.Parameters.Add("@NOM", nom);
ODC.Parameters.Add("@CIN", CIN);
ODC.Parameters.Add("@MAT", Mat); Particularly with a web based application, there is a high risk of an deliberate or accidental SQL Injection attack which non-parametrised queries are wide open too.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Hi Pierre as OriginalGriff suggested you a perfect way to save data in MYSQL i will also suggest you to use Parametrized query against database(MYSQL)
you can take a look there[^] and there[^] to learn how to use parametrized query to prevent SQL Injection Attack.
|
|
|
|
|
Is it possible, without wierd try to open the file and if failed sleep a while then try again or sleep after create event 30 seconds to make sure large file is copied, wait for file copy completion event?
It fires event too soon before the file is completely copied.
Чесноков
|
|
|
|
|
I assume you´re talking about some kind of service on the receiving machine?
For situations like this, I don´t hook into the "creation" event, I use the "rename" event. First copy, then rename -> your watcher sees it
I cannot remember: What did I before google?
|
|
|
|
|
no, I have to catch when large file is copied into the folder, e.g. 0.5-1Gb
Чесноков
|
|
|
|
|
I've done some extsnsive FileSystemWatcher work (check this article series - part 2 is especially interesting[^]). It it were me, I'd wait for the created event, and then start a thread that tried to achieve an exclusive open on the file in question. Once that is achieved, the copy process is most likely finished.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "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
|
|
|
|
|
You have to use a Windows API function call to check for the operation to be completed (or you can spin in managed code catching exceptions). After all, in the MS world no one writes to a file to the subsequently use said file.
|
|
|
|
|
I tend to use a second, very small file, which creates/writes/closes in a jiffy after the huge file has been processed. Then the FSW has to watch the small file only.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Something to ponder. What effect would the kernel transaction manager have here?
|
|
|
|
|
Just to be clear, there is no "completion event". The FSW tells you when a file is CREATED, not when a copy operation is going on.
A file copy operation is just an application (Explorer) opening one file for read and another file for write. Read the bytes from one file and write them to another.
The FSW cannot tell what is going on with the files.
But, yeah, your code has to respond to the Created event from the FSW, then start trying to open the file for read with exclusive access (ShareDenyAll). If the open statement fails, wait for a few seconds, then try it again. When you finally get the file open, your copy operation should be done. Close the file and process to do whatever you wanted with the file.
|
|
|
|
|
Hello,
trying to build a Windows programm, I 've declared an object in Fornm1.cs by typing
Person[] P = new Person[10];
after a class Person I 've created on another file called Person.cs
Then on the function that is being activated after clicking on a button inside the Form I pass simple numerical values to a member attribute like below:
private void btnObjectAdd_Click(object sender, EventArgs e)
{
lbltest_i.Text = i.ToString();
P[i] = new Person();
P[i].category = i;
i++;
if (i == 10)
{
for (i = 0; i < 10; i++)
P[i] = null;
i = 0;
}
}
Thus I get P[0]=0, P[1]=1, ... P[9]=9.
Then I try to call a value of an object on another function like
private void showToolStripMenuItem_Click(object sender, EventArgs e)
{
int value = P[2].category;
}
and I get value = 2.
This works perfect.
But if I change
int value = P[2].category;
into
int value = P[i].category;
then I get an error that I should create an object with 'new'.
Variable i is declared as
int i = 0;
outside the functions but inside the
public partial class Form1 : Form
Is that the problem?
modified on Monday, February 7, 2011 1:14 PM
|
|
|
|
|
There seems to be something very wrong with your design. But if "i" is declared in the same class as your showToolStripMenuItem_Click code then there should be no reason why that is the problem. Perhaps you need to post more of your code - and please you the PRE tags to format is more readably.
return 5;
|
|
|
|
|