|
Or if you are lazy and have .Net 2.0, just use the Ping class.
Ping ping = new Ping();
byte[] buf = new byte[32];
for (int b = 0; b < buf.Length; b++)
{
buf[b] = (byte)(b + 65);
}
for (int i = 0; i < count; i++)
{
PingReply reply = ping.Send(ipAddress, buf, 2000);
if (reply.Status == IPStatus.TimedOut)
{
Console.Out.WriteLine("Request Timed Out");
}
else
{
Console.Out.WriteLine(reply.Status.ToString());
}
}
|
|
|
|
|
Thanks for the link and the code.
amar
|
|
|
|
|
Hi,
I have a window in C# with windows.forms that uses a Splitter. I have two controls, one left and one right, with the Splitter in between. Now, when I resize the window the controls aren't 'updated': all I get is some empty dialog space between the bottom of the controls and the bottom of the window. When I then resize the Splitter a bit, all controls are updated. Is there a way to do this updating when I'm resizing the window? Thanks.
cheers,
roel
|
|
|
|
|
I've found the splitter to work best with docked controls.
|
|
|
|
|
Hi,
I'm looking for a tool for Visual Studio .NET. Maybe Someone can help me.
The background ist:
I want to bulid a Simulationtool, which simulates several sessions in batch mode. A couple of parameters are there to define the workflow for every session. This workflows are very complex and I must cange it every week. So I'm looking for a tool, to design a finite state machine in a graphic way.
I don't know if something like this exist. Maybe this tool can produce a *.dll, which I can implement in my Solution (VS.NET C#). This dll can control my workflow with events and delegates or reflections.
I know, this is very abstract
Thx for Info.
David
|
|
|
|
|
|
Yes, I think that's nice.
But very expensive.
Thanks for the support.
David
|
|
|
|
|
|
Wow,
this UniMod tool is pretty cool. That's exact what I'm looking for. But for Visual Studio and not for Eclipse.
I know there will be a graphical class designer in Visual Studio 2005. Nut I'm not sure if the class-designer will have the same possibilities like the UniMod tool?
Sincerely,
David
|
|
|
|
|
Hi,
how can i map virtual path or uri to physical path in form application(not asp.net)
Sincerely,
|
|
|
|
|
how do i query dataset with sql statement
|
|
|
|
|
|
If you've already got a populated dataset, you could do the following:
Let's say you got a DataSet (ds) with a 'Customer' Table, and you want all the customers that have a first name of 'Paul'
DataView dv = new DataView(ds.Tables["Customer"]) ;
dv.RowFilter = "FirstName = 'Paul'" ;
Now, you have records that have 'Paul' in the FirstName field, in your DataView.
Is that what you meant?
|
|
|
|
|
hmm..maybe
yes i have dataset already populated
but is there a way to execute a sql command on dataset data
|
|
|
|
|
Yes.
** To execute a stored procedure, that gets the value of an output parameter
//you need to have a SqlConnection object
SqlCommand something = new SqlCommand("StoredProcName",[sqlConnection]) ;
something.CommandType = CommandType.StoredProcedure ;
//for each paramter in the stored proc, do the following
something.Parameters.Add(@Parm1, SqlDbType.Int) ;
something.Parameters["@Parm1"].Direction = ParameterDirection.InputOutput ;
something.Parameters["@Parm1"].Value = [in this case an integer value] ;
something.ExecuteNonQuery() ;
Int32 somevalue = Convert.ToInt32(something.Parameters["@Parm1"].Value) ;
** there are many ways to deal with executing Sql Commands. You can set up a SqlCommand for dataadapters for automatically updating your dataset, you can also use SqlCommand to just execute a sql statement. Look in your MSDN help for more info on this, or search CodeProject articles ... there are lots of them on this issue.
|
|
|
|
|
You can use the Select() of a datatable...
<br />
DataSet ds = new DataSet();<br />
DataTable table = ds.Tables.Add();<br />
table.Columns.Add("Name", System.String);<br />
table.Columns.Add("Value", System.String);<br />
table.Rows.Add(new string[] {"David", "one"});<br />
table.Rows.Add(new string[] {"George", "two"});<br />
<br />
DataRow[] resultRows = table.Select("Name Like 'D%'");<br />
Hope it helps!
-Cursor
|
|
|
|
|
it helps! thx!
|
|
|
|
|
I've written a C# winform app and I'm new on C#...but I've some experience in programming...
I've some problems that I can't found anywhere a resolution...
My program is designed to have a main MDI form and a lot of MDI childs...so my questions are:
1)I create dinamically menu on MDI form and I've assigned to each of the a shortcut...but for the first element (i.e. "&File" menu than I've assigned Shortcut.CTRLF) it doesn't work...why?!?
the code is this:
void menuBuilder(object sender, System.EventArgs e)
{
MainMenu mainMenu = new MainMenu();
MenuItem file = new MenuItem();
file.MergeOrder=0;
file.MergeType=MenuMerge.MergeItems;
file.Text="&File";
file.Index=0;
file.Shortcut=Shortcut.CtrlF;
mainMenu.MenuItems.Add(file);
this.Menu=mainMenu;
}
2)I have a MDI child open correctly in my app from MDI menu (that I'll call FORM1) and I want that from FORM1, when it's loaded, to open another MDI child (FORM2) with a datagrid inside it.To do this I do this...
FORM2 newMDIChild = new FORM2();
newMDIChild.MdiParent = this.MdiParent;
newMDIChild.Show();
I suppose that in this manner I can load FORM 2 as a MDI child but it not seems to work, becouse if I tested if the window is open it doesnt works...and open another window!
2a)I try to close FORM2 when I close FORM1 but I can never do it...how can I do?!?I try everything but never works...
2b)When I do some works on FORM1, I write something on an ACCESS DB and then I'd like FORM 2(that is active too) update datagrid inside it...but I try everything but nothing work!!!I try to call a method on FORM2 from FORM1 becouse I suppose that it updates my datagrid...
The code is:
public void ReadResults()
{
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbConnection con =new OleDbConnection();
OleDbCommand cmd = new OleDbCommand();
DataTable dt =new DataTable();
dt.Clear();
con.ConnectionString=<connstr>;
con.Open();
cmd.Connection = con;
cmd.CommandText = "SELECT * FROM TBL";
da.SelectCommand = cmd;
da.Fill(dt);
dataPreResult.SetDataBinding(dt,"");
cmd.Cancel();
con.Close();
}
I call this method on FORM2_Load and work fine...but if I want to reload datagrid when the FORM2 is displayed...what I've to do?!?
Help me please...I know that this are very stupid questions...but I didnt find anything everywhere that can help me...
|
|
|
|
|
You forgot to add click event & handler in your first block of code.
You can rewrite your code and add required functionality.
void menuBuilder(object sender, System.EventArgs e)<br />
{<br />
MainMenu mainMenu = new MainMenu();<br />
<br />
MenuItem file = new MenuItem();<br />
file.MergeOrder=0;<br />
file.MergeType=MenuMerge.MergeItems;<br />
file.Text="&File";<br />
file.Index=0;<br />
file.Shortcut=Shortcut.CtrlF;<br />
file.Click+=new EventHandler(file_Click);<br />
mainMenu.MenuItems.Add(file);<br />
<br />
this.Menu=mainMenu;<br />
}
private void file_Click(object sender, EventArgs e)<br />
{<br />
<br />
MessageBox.Show("Clicked");<br />
}
And i am sorry about your second queary. Because i can not figurout what you really want to achive.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
But if File menu has submenus...what event I've to set for him?
something like this...
void menuBuilder(object sender, System.EventArgs e)
{
MainMenu mainMenu = new MainMenu();
MenuItem file = new MenuItem();
file.MergeOrder=0;
file.MergeType=MenuMerge.MergeItems;
file.Text="&File";
file.Index=0;
file.Shortcut=Shortcut.CtrlF;
file.Click+=new EventHandler(file_Click);
mainMenu.MenuItems.Add(file);
MenuItem campionato = new MenuItem();
campionato.MergeOrder=1;
campionato.MergeType=MenuMerge.MergeItems;
campionato.Text="&Campionato";
campionato.Click += new EventHandler(Championship_Open);
campionato.Shortcut=Shortcut.CtrlC;
campionato.ShowShortcut=true;
file.MenuItems.Add(campionato);
this.Menu=mainMenu;
}
private void file_Click(object sender, EventArgs e)
{
}
Will works or...not?
For second question...probably I'm confused...
In brief...I've a MDI application with this MDI childs(at the moment all MDI childs are closed):
1)MDIFORM (MDI container)
2)FORM1 (MDI form child)
3)FORM2 (MDI form child)
I press a menu on MDIFORM that opens FORM1.
In FORM1 there is a texbox and 1 button(btnOk).
On keyPress event of textbox I write in a MSAccess DB what I'm writing in a table.
Then I press a button and on click event I call this method btnOk_Click:
public class FORM1: System.Windows.Forms.Form
{
private void btnOk_Click(object sender, System.EventArgs e)
{
FORM2 newMDIChild = new FORM2();
newMDIChild.MdiParent = this.MdiParent;
newMDIChild.Show();
}
}
In FORM2 I've a datagrid where I show results written before in last MSAccess table.The code is this:
public class FORM2 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
private System.Windows.Forms.DataGrid dataPreResult;
public FORM2()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.dataPreResult = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dataPreResult)).BeginInit();
this.SuspendLayout();
//
// dataPreResult
//
this.dataPreResult.AllowSorting = false;
this.dataPreResult.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.dataPreResult.DataMember = "";
this.dataPreResult.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataPreResult.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.dataPreResult.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataPreResult.Location = new System.Drawing.Point(0, 0);
this.dataPreResult.Name = "dataPreResult";
this.dataPreResult.ReadOnly = true;
this.dataPreResult.RowHeaderWidth = 10;
this.dataPreResult.Size = new System.Drawing.Size(232, 613);
this.dataPreResult.TabIndex = 0;
//
// FORM2
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(232, 613);
this.Controls.Add(this.dataPreResult);
this.Location = new System.Drawing.Point(600, 10);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FORM2";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Load += new System.EventHandler(this.StringPreResult_Load);
((System.ComponentModel.ISupportInitialize)(this.dataPreResult)).EndInit();
this.ResumeLayout(false);
}
#endregion
public void StringPreResult_Load(object sender, System.EventArgs e)
{
ReadResults();
}
public void ReadResults()
{
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbConnection con =new OleDbConnection();
OleDbCommand cmd = new OleDbCommand();
DataTable dt =new DataTable();
dt.Clear();
con.ConnectionString=<connectionstring>;
con.Open();
cmd.Connection = con;
cmd.CommandText = "SELECT * FROM TABLE";
da.SelectCommand = cmd;
da.Fill(dt);
dataPreResult.SetDataBinding(dt,"");
cmd.Cancel();
con.Close();
}
}
So now, my problems are:
1)When I push another time btnOk on FORM1 another FORM2 is showed.How can open one window?
2)if when I push MDIFORM menu's, when I open FORM1, I'll open FORM2 too, how can update datagrid in FORM2 from FORM1 when i write on FORM1 textbox?
Thanks for any ideas!
|
|
|
|
|
Instead of creating a new FORM2 everytime when the button is clicked, create a member variable of type FORM2 in FORM1, initializing it to null. In the event handler, test against null before creating the second form.
<br />
public class FORM1: System.Windows.Forms.Form<br />
{<br />
private FORM2 _secondForm = null;<br />
<br />
private void btnOk_Click(object sender, System.EventArgs e)<br />
{<br />
if (this._secondForm == null)<br />
{<br />
this._secondForm = new FORM2();<br />
this._secondForm.MdiParent = this.MdiParent;<br />
}<br />
<br />
this._secondForm.Show();<br />
}<br />
}<br />
This is just a simple fix, usually I try to have my mdi container manage my form instances.
In regards to your question regarding the second form accessing the first's textbox text, you could have the first form pass the second form a reference to itself. Again, this is much cleaner by having the MdiContainer manage interactions between child forms.
-cursor
|
|
|
|
|
Thanks for your answer...for the first question I try and it works great!
<b>And with the same method...I can close FORM2 from FORM1?</b>
For the second question, that's very important for me...could you give me an example how to solve this problem?I dont have so much experience with C# language to solve it...
Someone told me that for solve this problem I've to create a static method in FORM2 and then I can call it from FORM2 but I try but it there is an error...
the code is...
public class FORM2 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
private System.Windows.Forms.DataGrid dataPreResult;
public FORM2()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.dataPreResult = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dataPreResult)).BeginInit();
this.SuspendLayout();
//
// dataPreResult
//
this.dataPreResult.AllowSorting = false;
this.dataPreResult.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.dataPreResult.DataMember = "";
this.dataPreResult.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataPreResult.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.dataPreResult.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataPreResult.Location = new System.Drawing.Point(0, 0);
this.dataPreResult.Name = "dataPreResult";
this.dataPreResult.ReadOnly = true;
this.dataPreResult.RowHeaderWidth = 10;
this.dataPreResult.Size = new System.Drawing.Size(232, 613);
this.dataPreResult.TabIndex = 0;
//
// FORM2
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(232, 613);
this.Controls.Add(this.dataPreResult);
this.Location = new System.Drawing.Point(600, 10);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FORM2";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Load += new System.EventHandler(this.StringPreResult_Load);
((System.ComponentModel.ISupportInitialize)(this.dataPreResult)).EndInit();
this.ResumeLayout(false);
}
#endregion
public void StringPreResult_Load(object sender, System.EventArgs e)
{
ReadResults();
}
public static void ReadResults()
{
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbConnection con =new OleDbConnection();
OleDbCommand cmd = new OleDbCommand();
DataTable dt =new DataTable();
dt.Clear();
con.ConnectionString=<connectionstring>;
con.Open();
cmd.Connection = con;
cmd.CommandText = "SELECT * FROM TABLE";
da.SelectCommand = cmd;
da.Fill(dt);
dataPreResult.SetDataBinding(dt,"");
cmd.Cancel();
con.Close();
}
}
I run code and this is the error:
<u><b>'FORM2.dataPreResult' denotes a 'field' where a 'class' was expected</b></u>
I'm so confused...what I've to do?
|
|
|
|
|
Nobody else can help me?
I dont know how to solve my problem...
|
|
|
|
|
Hi,
I’m currently writing a POS (Point Of Sale) system in c# with the database stored in sglexpress (using .Net 2).
Is there any kind of framework out there for this?
I would appreciate any tips, not just code but also UML and general ideas about it.
Thanks
Carl-Johan Larsson
|
|
|
|
|
hey,
would anyone plz tell me how the 'custom treeview' is created at runtime?
as in windows form...
if i have to create the same using remoting...plz do tell
|
|
|
|