|
hi
use the FolderBrowserDialog in the forms namespace
|
|
|
|
|
|
how can i move a label that is in a panel? i dont know what to do in the draganddrop event of the panel. how do i relocate the label? do i need the pointtoclient?
here's the code:
static void newPanel_DragDrop(object sender, DragEventArgs e)
{
}
static void newPanel_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Move;
}
|
|
|
|
|
hi
Just see this code for tabcontrol,selecting the required tabpage from tabcontrol1 and dragging form tabcontrol1 and drop it tabcontrol2.
I hope this will be helpful for u.
private void tabControl1_MouseMove( object sender, MouseEventArgs e )
{
if ( e.Button == MouseButtons.Left )
tabControl1.DoDragDrop( tabControl1.SelectedTab, DragDropEffects.All );
}
private void tabControl2_DragEnter( object sender, DragEventArgs e )
{
e.Effect = e.Data.GetDataPresent( typeof( TabPage ) )
? DragDropEffects.Move
: DragDropEffects.None;
}
private void tabControl2_DragDrop( object sender, DragEventArgs e )
{
TabPage DropTab = (TabPage)( e.Data.GetData( typeof( TabPage ) ) );
tabControl2.TabPages.Add( DropTab );
}
WiNNING IS NOT OUR DREAM,IT'S A HABIT
Have a nice evening
|
|
|
|
|
Hi All,
I am developing a windows application. In that application I have to write an entry in eventlog at the time when the application is closed. The problem is that application dont have any UI(User Interface) so it can closed only through taskmanager.
So is there any method or exception to catch it and then send an entry catching it in eventlog.
Regards,
Parag
|
|
|
|
|
i need to know that if many values are entered into a c# form, then i want to add all those in
the dataBase.so what will be the code lines.plz reply someone
|
|
|
|
|
Create a SqlCommand to INSERT the data in the database.
SqlCommand cmd = new SqlCommand();
cmd.Connection = aConnection;
cmd.CommandText = "INSERT TableName(Column1, Column2, Column3) "+
"VALUES (@Value1, @Value2, Value3";
cmd.Parameters.Add("@Value1", theFirstValue);
cmd.Parameters.Add("@Value2", theSecondValue);
cmd.Parameters.Add("@Value3", theThirdValue);
cmd.ExecuteNonQuery();
You will have to replace theFirstValue , theSecondValue and theThirdValue with appropriate values. Also, you will have to restructure the INSERT statement to match your database. I've also assumed that you have a connection (aConnection ) to the database.
|
|
|
|
|
hi
First write StoredProcedure like for Insert
Create StoredProc nameofStoredProc
(
@firstname varchar(20),
@lastname varchar(20))
as
insert into tablename
(
firstname,
lastname
)
values
(
@fisrtname,
@lastname
)
then start writing ADO.net code
SqlConnection con=new SqlConnection("userid=""; password="";DataSource="");
con.Open();
SqlCommand cmd=new SqlCommand("nameofStroredProc",con);
cmd.CommandType=CommandType.StoredProcedure;
cmd.Parameter.Add(new SqlParameter("@firstname",SqlDbType.varchar);
cmd.Parameter.Add(new SqlParameter("@lastname",SqlDbType.varchar);
cmd.parameter[0].value= txtFirstName.text;//textbox value
cmd.Parameter[1].value=txtlastName.Text;//textbox value
cmd.ExecuteNonQuery();
con.Close();
WINNING IS NOT OUR DREAM, IT'S A HABIT
HAVE A NICE DAY
|
|
|
|
|
dornala wrote: SqlConnection con=new SqlConnection("userid=""; password="";DataSource="");
A SqlConnection needs both a server and database name. Also, It is better to use a trusted connection than supply a user name and password in plain text.
|
|
|
|
|
hi
Just Iam specifing a simple connection for an example.
It is good practice to give entire connection object.
|
|
|
|
|
dornala wrote: It is good practice to give entire connection object.
I don't understand what you mean. What is a simple connection? The only way to connect to a database with ADO.NET is with a connection object.
|
|
|
|
|
Hi
I wonder if anyone can help with this one, I've tried casting round on the net but couldn't find a solution.
I'm working on an MDI winforms app which contacts a web service to retrieve data. I use the MdiChild form Icon, linked to a Timer, to mimic am animated gif whilst the app is away fetching data - giving the app users a sense that something is happening:
<br />
private void TimerIconWorking_Tick(object sender, System.EventArgs e)<br />
{<br />
if (this.Icon.Equals(this._IconWorking)) <br />
this.Icon = this._IconWorking90;<br />
else if (this.Icon.Equals(this._IconWorking90)) <br />
this.Icon = this._IconWorking180;<br />
else if (this.Icon.Equals(this._IconWorking180)) <br />
this.Icon = this._IconWorking270;<br />
else if (this.Icon.Equals(this._IconWorking270)) <br />
this.Icon = this._IconWorking;<br />
else
TimerIconWorking.Enabled = false;<br />
}<br />
This works prefectly well while the MdiChild WindowState is Normal, however, once I maximize the form the MdiChild Icon does not get redrawn via the timer event. [Note this is the MdiChild (form level) Icon, not the MdiParent (application level) Icon.] The event fires fine, the code above gets executed as expected, but the Icon is not refreshed - except when I click off the app while the timer event is executing; then the redraw happens... (I think this is a clue but I'm not sure how to interpret it!)
I've tried to force the app to refresh by adding something like this to the event above but to no avail:
<br />
if ((this.WindowState == FormWindowState.Maximized)&&(this.MdiParent != null))<br />
{<br />
}<br />
1) Is there any obvious way to force a refresh the MdiChild form Icon whilst the form is maximized?
2) If the MdiParent.Menu area (where the MdiChild.Icon resides when the MdiChild is maximized) is rendered by Windows, rather than by the MdiParent, is there any way to force Windows to render this area of the MdiParent?
Cheers
HN3
|
|
|
|
|
Hi,
Try to use this line of code to refresh instead the Refresh() method.
Application.DoEvents();
|
|
|
|
|
Hi there,
Thanks for taking the time to reply, unfortunately this doesn't have any effect.
Cheers,
HN3
|
|
|
|
|
i want to reterive from dataset to fill my report
but i don't know how to do that
can i body tell me how
ma_refay
|
|
|
|
|
|
hi
First place report control on form and Add crystalreport to project by click ing AddNewItem add select CrystolReport template item,
gothrough one by one to add Database And its Coumns,
here is the code in ADO.net
MySqlConnection conn;
MySqlCommand cmd;
MySqlDataAdapter adap;
conn = new MySqlConnection("Server=localhost; Database=saf; User ID=root; Password=root; charset=utf8;"); conn.Open();
cmd = conn.CreateCommand();
cmd.CommandText = "SELECT customer_code, customer_name, customer_address FROM Customers";
adap = new MySqlDataAdapter();
adap.SelectCommand = cmd;
DataSet ds=new DataSet();
adap.Fill(custDB, "Customers");
CrystalReport1 myReport = new CrystalReport1();
crystalReportViewer1.ReportSource = myReport;
Winning is not our dream, It's a habit...
Have a nice evening
|
|
|
|
|
Hello
can someone tell me the method to retrieve the text of a cell that is selected at runtime in a DataGrid.
plz keep in mind that im working with .Net 2003 and do not have the DataGridView option.
Saira
|
|
|
|
|
if(dataGrid1.CurrentCell != null)
value = dataGrid1[dataGrid1.CurrentCell].ToString();
life is study!!!
|
|
|
|
|
SeishinLovesC#
u're the best
regards
Saira
|
|
|
|
|
With coding, or using remote connection type software such as Remote Desktop?
He who laughs last is a bit on the slow side
|
|
|
|
|
Hi,
I write this code in the "CurrentCellChanged" event
private void dataGirdView1_CurrentCellChanged(object sender, EventArgs e)
{
txtName.Text = dataGirdView1[1, dataGirdView1.CurrentRow.Index].Value.ToString();
}
But this exception occur that when DataGirdView fiiling;
System.NullReferenceException: Object reference not set to an instance of an object
|
|
|
|
|
private void dataGirdView1_CurrentCellChanged(object sender, EventArgs e)
{
if(dataGirdView1.CurrentRow!=null)
txtName.Text = dataGirdView1[1,dataGirdView1.CurrentRow.Index].Value.ToString();
}
life is study!!!
|
|
|
|
|
I try dataGirdView1.CurrentRow.Index but its not work. It's big mistake.
Your code is working, thanks a lot...
|
|
|
|
|
my SendMessage project code:
private void button1_Click(object sender, EventArgs e)
{
IntPtr tohandle = FindWindow(null, "Sub Form");
Point pt = new Point(99, 100);
int iSize = Marshal.SizeOf(typeof(Point));
IntPtr lp = Marshal.AllocHGlobal(iSize);
Marshal.StructureToPtr(pt, lp,true );
if ((int)tohandle != 0)
{
SendMessage(tohandle, 789, IntPtr.Zero , lp);
}
}
my recieve msg project code :
protected override void DefWndProc(ref Message m)
{
if (m.Msg == 789)
{
Point pt = (Point)Marshal.PtrToStructure(m.LParam, typeof(Point));
string message = string.Format("{0},{1},{2},{3}",m.Msg ,m.WParam,pt.X ,pt.Y );
this.listBox1.Items.Add(message);
}
base.DefWndProc(ref m);
}
my issue:
m.Msg and m.WParam is ok ,but pt is error data, Why?
|
|
|
|