|
pls try this code , i hope it can help
1-drage a button1 on your form
2-set its visible proprty to false in thje proprties window
3-drage a picturebox1
4-double clic pic box & u,ll find
private void pictureBox1_Click(object sender, System.EventArgs e)
{
}
this is an event defination so replace "click" with "DoubleClick" like this
private void pictureBox1_DoubleClick(object sender, System.EventArgs e)
{
}
5-open the +win form generated desiner generated code
6-open the + private void intialize component
7-search for this
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
8-replace with
this.pictureBox1.DoubleClick += new System.EventHandler(this.pictureBox1_DoubleClick_1);
9-private void pictureBox1_DoubleClick_1(object sender, System.EventArgs e)
{
button1.Visible=true;
}
where button1 is the button1
feel free to e-mail me at c__lover@hotmail.com
The C Lover ..
|
|
|
|
|
I am fairly new to C# and am trying to export the text from a multi-line textbox to an external file. I am familiar with SaveFileDialog when exporting the contents of a DataGrid, but am unsure as to how I would assign the textbox data.
Here is what I would have done if I were exporting the data from a C1TrueDBGrid. I am sure that I am just missing something simple
-------------------------------------------------------
protected virtual void Export()
{
System.Windows.Forms.SaveFileDialog saveFileDialog = new SaveFileDialog() ;
saveFileDialog.Filter = "Excel |*.csv|Text|*.txt" ;
saveFileDialog.InitialDirectory = @"C:\" ;
saveFileDialog.OverwritePrompt = true ;
saveFileDialog.FileName = "dbview_" + this.tableName.Replace(" ", "");
saveFileDialog.Title = "Database View for " + this.tableName.TrimEnd() ;
saveFileDialog.ShowDialog() ;
try
{
if (System.IO.File.Exists(saveFileDialog.FileName))
{
System.IO.File.Delete(saveFileDialog.FileName) ;
}
this.c1TrueDBGrid1.ExportToDelimitedFile(saveFileDialog.FileName,
C1.Win.C1TrueDBGrid.RowSelectorEnum.AllRows, ",", "", "", true, "ASCII") ;
System.Diagnostics.Process.Start(saveFileDialog.FileName) ;
}
catch {}
}
|
|
|
|
|
Here is part of an example from MSDN that shows how to write text to a file:
StreamWriter sr = File.CreateText(FILE_NAME);<br />
sr.WriteLine ("This is my file.");<br />
sr.WriteLine ("I can write ints {0} or floats {1}, and so on.", 1, 4.2);<br />
sr.Close();
---
b { font-weight: normal; }
|
|
|
|
|
That was exactly what I needed and worked great! Thanks and have a good one!
|
|
|
|
|
I am having trouble to set my drawing shape in center. When I used translatetransform and it went perfect center. But when I used scaletransform, it went bigger and went different locations. I didnt get it at all. I tried to do different methods and I still dont get it. tell me what is going on. Thanks!!
private void Part_PreviewPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
GraphicsPath grfxPath = new GraphicsPath();
//
//added grfx by using graphicspath shape:line,arc,etc///
//
float fMidPointX = nPanelWidth/2;
float fMidPointY = nPanelHeight/2;
e.Graphics.TranslateTransform(fMidPointX,-fMidPointY);
e.Graphics.ScaleTransform(7.0f,7.0f);
e.Graphics.DrawPath(new Pen(Color.Black, .03f),grfxPath);
}
|
|
|
|
|
All transformation you do are composite of each other.
If you translate and then scale, then the translate will also be scaled.
To get your desired effect, divide you translate by your scale:
float fMidPointX = nPanelWidth/2;
float fMidPointY = nPanelHeight/2;
e.Graphics.TranslateTransform(fMidPointX/7f,-fMidPointY/7f);
e.Graphics.ScaleTransform(7.0f,7.0f);
e.Graphics.DrawPath(new Pen(Color.Black, .03f),grfxPath);
your pen will also be scaled, so instead of now being 0.03f, it will be 0.21f
|
|
|
|
|
Hi
I have a TapControl witch contains Open, Settings, Grade, Statistics and Queries taps and I arranged them in the collection property in the above arrangement. But, when I execute my program it arrage them as Open, Settings, Statistics, Queries, Grade. It was working well and I faced this problem today and tried to solve it but nothing..
please help.
|
|
|
|
|
|
I am not using stored procedures, my table looks like this:
+---------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+----------------+
| ProviderID | int(11) | | PRI | NULL | auto_increment |
| CompanyTitle | varchar(255) | YES | | NULL | |
| CompanyEmail | varchar(50) | YES | | NULL | |
| Website | varchar(50) | YES | | NULL | |
+---------------+--------------+------+-----+---------+----------------+
The value of ProviderID is automatically generated by the database, to insert data into the table, I am using the following code:
MySqlCommand myInsertCmd = new MySqlCommand(
"INSERT INTO myTable (ComapanyTitle, CompanyEmail, Website, ContactPerson, AddressID)
VALUES(?CompanyTitle, ?CompanyEmail, ?Website, ?ContactPerson, ?AddressID)", myConnection);
myInsertCmd.Parameters.Add("?CompanyTitle", MySqlDbType.VarChar,
255, "CompanyTitle");
myInsertCmd.Parameters.Add("?CompanyEmail", MySqlDbType.VarChar, 50, "CompanyEmail);
myInsertCmd.Parameters.Add("?Website", MySqlDbType.VarChar, 50, "CompanyEmail);
myAdapter.InsertCommand = myInsertCmd;
now, whenver I get a new row, I immediately insert it into the database, like this:
myAdapter.Update(myDataTable);
Is there a way, I can get the primaryKey of the newly insert row?
Thanks...
- A programmer's national anthem; "AAAAAHHHHH!!!!"
|
|
|
|
|
|
Ok, I am lost with these UserControls and passing inforamtion between them.
I have two projects set up in my solution. The first project contains a form and refrences the other one. The other one has my UserControls and Person Class in it.
The Design is:-->
I have a form and on that form I have two of my own usercontrols.
One is a control with three text boxs on it and an add button and a cancel button. the other UserControl has just a listbox.
What I want to do is have the user fill in the text boxes with personal information (name,age)
and then hit the add button and have that displayed in the list box on the other userControl.
Where I'm having trouble is when I'm trying to access the listbox from the add button event.
Since the list box is in another usercontrol I just can't say this.listbox1.text = whatever" . Can someone help me on this?
(FOR RIGHT NOW IT COULD BE JUST A WORD, I JUST NEED TO UNDERSTAND USERCONTROL INTERACTION when placed on a form separately)
Thanks.
The greatest gig .... LIFE!
|
|
|
|
|
Why to use two UserControls? Wouldn't be two GroupBoxes better?
OK, if you have separated UserControls which share some data, put these data into higher level of hierarchy.
An other way is to make reference in one control to another one, or one's ListBox (via property).
If I would solve this problem myself, I would use some collection (like PeopleCollection). The Add button would be in second UserControl, which controls the collection and keeps one person active. First UserControl would just edit the properties of Person and contains some Apply button which changes the properties of active person (first control contains some ActivePerson property).
Hope this helps a bit.
|
|
|
|
|
I have a C DLL that defines a structure like this
<br />
struct Data<br />
{<br />
int iLength;<br />
UCHAR *buff;<br />
<br />
};<br />
<br />
void AllocateData(Data *pData);<br />
void FreeData(Data *pData);<br />
The buffer inside the structure is allocated inside the C DLL and the buffer lenght is provided in the iLength upon return.
I want to use by creating C# marshalling layer to these function in C#. I have the declaration like this
<br />
[ StructLayout( LayoutKind.Sequential )] br />
public struct Data<br />
{<br />
public int iLength;<br />
}<br />
<br />
[ DllImport( "Data.dll", <br />
EntryPoint="AllocateData", <br />
ExactSpelling=true, // Bypass A or W suffix search<br />
CharSet=CharSet.Ansi, // We want ANSI String<br />
CallingConvention=CallingConvention.Cdecl ) ] br />
public static extern void AllocateData(ref Data data);<br />
<br />
I cannot understand what to use for UCHAR pointer and how to allocate the structure before calling the DLL function.
|
|
|
|
|
Hello gurus,
I am fighting with the MdiChildActivate event.
I would like to know how this works. There is no sample in the MSDN and this event seems to be mysterious: it seems that nobody has used this on this forum. The reserach gave me no result
So, what I need to do is the following:
When an mdi child is brought to front by clicking on it, I wish to know which child is this in order to refresh the main window title, its properties (via a PropertyGrid placed in the main MDI form) and selecting the corresponding node (in its 'solution explorer' which is a TreeView ). My application handles 3 types of different documents.
Can someone help me and showing me a code snippet please? I'm not familiar with MDIs in C#. Sorry for asking the question.
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
Hello,
Is there a nice way of masking the textbox, so that if user has
the amount in the textbox = 45000, the textbox will display it as money amount like that: $ 45,000.
Thank you in advance.
|
|
|
|
|
zaboboa wrote:
Is there a nice way of masking the textbox
There used to be a control called the Masked Edit that made this simple. But I don't think you can put this control on a current Windows Form.
But you can make your own inherited control to do the same thing. Just inherit from TextBox and override the OnKeyPress method to modify the text entered by the user according to the desired mask. You could design it such that the constructor takes a definition of the mask as a parameter.
Sound like too much work? Then just use this[^].
Marshall
If you continue to do the same things you always did, don't be surprised if you get the same results you always got.
|
|
|
|
|
instead of using onkeypress why don't u use on text change; what about pasting in to the control. But u are using data bound controls try to see BaseBindingManager.Format and .Parse events
|
|
|
|
|
I don't understand? What's BaseBindingManager? Who will that relate to my TextBox?
Thank you
|
|
|
|
|
I have a dialog form and appears on the top of MDIContainer (frmMain)
and I want when the user close the dialog form then an MDIChild should
be open on the frmMain. I tried:
myMDIChild.MdiParent = frmMain();
myMDIChild.Show();
but it didn't work.. I also tried:
frmMain MainForm = new frmMain();
myMDIChild.MdiParent = MainForm;
myMDIChild.Show();
with no luck. I am not getting any error message but the MDIChild form
is not openning..
Many Thanks,
Jassim Rahma
|
|
|
|
|
Hi,
In the parent window do the following:
myMDIChild.MdiParent=this;
MDIChild.Show();
This code has to be called in the frmMain() class.
Fred.
There is no spoon.
|
|
|
|
|
but the container is not (this).. i am running this code from frmNew() but the mdi container is frmMain()
|
|
|
|
|
in that case, set the IsMdiContainer to true and set the MdiParent property of the myMDIChild class to the new created form.
This should work.
Fred.
There is no spoon.
|
|
|
|
|
let me understand..
my main form is frmMain
my child form is frmChild
the active dialog is frmDialog
a user clicked a button which shows a frmDialog and when the user click on the button on the frmDialog it should close it and open frmChild within the container (frmMain)
so you want to say in frmDialog i should have this:
frmData frmChild = new frmData();
frmChild.MdiParent = frmMain();
frmChild.Show();
I tried that but getting this error:
dialog_form.cs(258): 'Ezi_Life.frmMain' denotes a 'class' which is not valid in the given context
|
|
|
|
|
Is this what you're looking for?
in MDI main form:
private void menuItem1_Click(object sender, System.EventArgs e)
{
DialogForm aDialogFormGUI = new DialogForm();
if (aDialogFormGUI.ShowDialog()== DialogResult.OK)
{
ThirdForm aThirdFormGUI = new ThirdForm();
aThirdFormGUI.MdiParent = this;
aThirdFormGUI.Show();
}
}
On the Dialog form in the Close event or Click;
DialogResult = DialogResult.OK;
Hope this helps.
|
|
|
|
|
yes.. it worked.. than you very much
can i ask one more question please
how can i run one instance of MDIChild so that if the user invoked the same option again it will not open a new MDIChild.. t should just bring the already openned MDIChild to front..
|
|
|
|