|
I think the GetHostbyAddress() method can help you.
the followed code is copyed from msdn:
try
{
IPAddress hostIPAddress = IPAddress.Parse(IpAddressString);
IPHostEntry hostInfo = Dns.GetHostByAddress(hostIPAddress);
// Get the IP address list that resolves to the host names contained in
// the Alias property.
IPAddress[] address = hostInfo.AddressList;
// Get the alias names of the addresses in the IP address list.
String[] alias = hostInfo.Aliases;
Console.WriteLine("Host name : " + hostInfo.HostName);
Console.WriteLine("\nAliases :");
for(int index=0; index < alias.Length; index++) {
Console.WriteLine(alias[index]);
}
Console.WriteLine("\nIP address list : ");
for(int index=0; index < address.Length; index++) {
Console.WriteLine(address[index]);
}
}
catch(SocketException e)
{
Console.WriteLine("SocketException caught!!!");
Console.WriteLine("Source : " + e.Source);
Console.WriteLine("Message : " + e.Message);
}
catch(FormatException e)
{
Console.WriteLine("FormatException caught!!!");
Console.WriteLine("Source : " + e.Source);
Console.WriteLine("Message : " + e.Message);
}
catch(ArgumentNullException e)
{
Console.WriteLine("ArgumentNullException caught!!!");
Console.WriteLine("Source : " + e.Source);
Console.WriteLine("Message : " + e.Message);
}
catch(Exception e)
{
Console.WriteLine("Exception caught!!!");
Console.WriteLine("Source : " + e.Source);
Console.WriteLine("Message : " + e.Message);
}
Just do it!
|
|
|
|
|
Hi
I am using window form with C# as code behind I have created a user control and trying to call in the window application .I am able to load the dll in the reference but in the "my user control" of the toolbox it doesn't gets loaded the page is blank.If I hardcode in code behined too it doesnt get loaded in the form(GUI).
I dont know what causing the problem .Have any idea what I am suppose to do.
sasi
|
|
|
|
|
use this link to get the solution.
this link specifies how to create a usercontrol.
I tried and it worked fine.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
vbwlkwalkthroughcreatinginheritedcontrolwithvisualc.asp
those who win are those who believe they can
|
|
|
|
|
Hi All.
I want to write some code that have some method that in create bitmap of the current screen.
What i mean is when this method is call - there will be create file in name X.bmp that contain the info of the screen ( line pressing on PrtScn button ).
How can i catch the picture ? what windows method (maybe API function) i need to use ?
|
|
|
|
|
Hello there!
I am trying to write a simple app that will monitor and save any changes in clipboard into some kind of an array.
I found some clipboard monitor examples online and they work great monitoring clipboard; however, when i try to save a string each time it is changed the program freaks out.
<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
using System.Runtime.InteropServices;<br />
<br />
namespace ClipboardMonitor<br />
{<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
[DllImport("User32.dll")]<br />
protected static extern int SetClipboardViewer(int hWndNewViewer);<br />
<br />
[DllImport("User32.dll", CharSet=CharSet.Auto)]<br />
public static extern bool ChangeClipboardChain(IntPtr hWndRemove, IntPtr hWndNewNext);<br />
<br />
[DllImport("user32.dll", CharSet=CharSet.Auto)]<br />
public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);<br />
<br />
private System.Windows.Forms.RichTextBox richTextBox1;<br />
<br />
IntPtr nextClipboardViewer;<br />
string dummy = "";<br />
int n = 0;<br />
string[] str_data = new string[50];<br />
private System.Windows.Forms.Button button1;<br />
private System.Windows.Forms.Button button2;<br />
<br />
private System.ComponentModel.Container components = null;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
nextClipboardViewer = (IntPtr)SetClipboardViewer((int) this.Handle);<br />
<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
ChangeClipboardChain(this.Handle, nextClipboardViewer);<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
private void InitializeComponent()<br />
{<br />
this.richTextBox1 = new System.Windows.Forms.RichTextBox();<br />
this.button1 = new System.Windows.Forms.Button();<br />
this.button2 = new System.Windows.Forms.Button();<br />
this.SuspendLayout();<br />
this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;<br />
this.richTextBox1.Location = new System.Drawing.Point(16, 16);<br />
this.richTextBox1.Name = "richTextBox1";<br />
this.richTextBox1.ReadOnly = true;<br />
this.richTextBox1.Size = new System.Drawing.Size(544, 88);<br />
this.richTextBox1.TabIndex = 0;<br />
this.richTextBox1.Text = "richTextBox1";<br />
this.richTextBox1.WordWrap = false;<br />
this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged);<br />
this.button1.Location = new System.Drawing.Point(184, 176);<br />
this.button1.Name = "button1";<br />
this.button1.TabIndex = 1;<br />
this.button1.Text = "button1";<br />
this.button1.Click += new System.EventHandler(this.button1_Click);<br />
this.button2.Location = new System.Drawing.Point(360, 176);<br />
this.button2.Name = "button2";<br />
this.button2.TabIndex = 2;<br />
this.button2.Text = "button2";<br />
this.button2.Click += new System.EventHandler(this.button2_Click);<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.ClientSize = new System.Drawing.Size(568, 273);<br />
this.Controls.Add(this.button2);<br />
this.Controls.Add(this.button1);<br />
this.Controls.Add(this.richTextBox1);<br />
this.Name = "Form1";<br />
this.Text = "Clipboard Monitor Example";<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
<br />
protected override void WndProc(ref System.Windows.Forms.Message m)<br />
{<br />
const int WM_DRAWCLIPBOARD = 0x308;<br />
const int WM_CHANGECBCHAIN = 0x030D;<br />
<br />
switch(m.Msg)<br />
{<br />
case WM_DRAWCLIPBOARD:<br />
DisplayClipboardData();<br />
store_data(n);<br />
n++;<br />
if(n == 50)<br />
{<br />
MessageBox.Show("STOP!");<br />
}<br />
SendMessage(nextClipboardViewer, m.Msg, m.WParam, m.LParam);<br />
break;<br />
<br />
case WM_CHANGECBCHAIN:<br />
if (m.WParam == nextClipboardViewer)<br />
nextClipboardViewer = m.LParam;<br />
else<br />
SendMessage(nextClipboardViewer, m.Msg, m.WParam, m.LParam);<br />
break;<br />
<br />
default:<br />
base.WndProc(ref m);<br />
break;<br />
} <br />
<br />
}<br />
<br />
void DisplayClipboardData() <br />
{<br />
try<br />
{<br />
IDataObject iData = new DataObject(); <br />
iData = Clipboard.GetDataObject();<br />
<br />
if (iData.GetDataPresent(DataFormats.Rtf)) <br />
richTextBox1.Rtf = (string)iData.GetData(DataFormats.Rtf);<br />
else if (iData.GetDataPresent(DataFormats.Text))<br />
richTextBox1.Text = (string)iData.GetData(DataFormats.Text);<br />
else<br />
richTextBox1.Text = "[Clipboard data is not RTF or ASCII Text]";<br />
}<br />
catch(Exception e)<br />
{<br />
MessageBox.Show(e.ToString());<br />
}<br />
}<br />
<br />
public void store_data(int n)<br />
{<br />
if(n!=0)<br />
{<br />
if(str_data[n - 1] == str_data[n])<br />
{<br />
n--;<br />
<br />
}<br />
else<br />
{<br />
str_data[n] = richTextBox1.Text;<br />
}<br />
}<br />
<br />
<br />
}<br />
<br />
private void richTextBox1_TextChanged(object sender, System.EventArgs e)<br />
{<br />
<br />
}<br />
<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
MessageBox.Show(str_data[0] + "\n" +<br />
str_data[1] + "\n" +<br />
str_data[2] + "\n" +<br />
str_data[3] + "\n" +<br />
str_data[4] + "\n" +<br />
str_data[5] + "\n" +<br />
str_data[6] + "\n" +<br />
str_data[7] + "\n" +<br />
str_data[8] + "\n" +<br />
str_data[9] + "\n" +<br />
str_data[10] + "\n" +<br />
str_data[11] + "\n" +<br />
str_data[12] + "\n" +<br />
str_data[13] + "\n" +<br />
str_data[14]+ "\n" +<br />
str_data[15] + "\n" +<br />
str_data[16] + "\n" +<br />
str_data[17] + "\n" +<br />
str_data[18] + "\n" +<br />
str_data[19] + "\n" +<br />
str_data[20] + "\n" +<br />
str_data[21] + "\n" +<br />
str_data[22] + "\n" +<br />
str_data[23] + "\n" +<br />
str_data[24] + "\n" +<br />
str_data[25] + "\n" +<br />
str_data[26] + "\n" +<br />
str_data[27] + "\n" +<br />
str_data[28] + "\n" +<br />
str_data[29] + "\n");<br />
<br />
MessageBox.Show(str_data[30] + "\n" +<br />
str_data[31] + "\n" +<br />
str_data[32] + "\n" +<br />
str_data[33] + "\n" +<br />
str_data[34] + "\n" +<br />
str_data[35] + "\n" +<br />
str_data[36] + "\n" +<br />
str_data[37] + "\n" +<br />
str_data[38] + "\n" +<br />
str_data[39] + "\n" +<br />
str_data[40] + "\n");<br />
<br />
}<br />
<br />
private void button2_Click(object sender, System.EventArgs e)<br />
{<br />
<br />
IDataObject d = Clipboard.GetDataObject();<br />
if(d.GetDataPresent(DataFormats.Bitmap)) <br />
<br />
{<br />
MessageBox.Show("Bitmap data is Contained in the clipboard.");<br />
} <br />
else if(d.GetDataPresent(DataFormats.Text)) <br />
{<br />
MessageBox.Show("Text data is Contained in the clipboard.");<br />
} <br />
else {<br />
MessageBox.Show("Some other format of data is Contained in the clipboard.");<br />
}<br />
}<br />
}<br />
}<br />
<br />
please help.
Also, you know how Excel has that clipboard where you can copy up to 12 items. How can i Access those items?
thanks
nnn
|
|
|
|
|
Hello everyone,
I have a DataGridView in a windows form with three columns:
Column1 is TipoComboBoxColumn
Column2 is QuantidadeColumn
Column3 is SementeComboBoxColumn
I need the SementeComboBoxColumn to display values according to the value I select in the TipoComboBoxColumn.
How do I go about accomplishing that? The code below works in part, BUT when I'm editing the value of SementeComboBoxColumn, the other values for the other rows in this column disappear. This is driving nuts!
private void tabBAdetDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (tabBAdetDataGridView.Columns[e.ColumnIndex].Name == "EspecieComboBoxColumn")
{
this.tabSementesTableAdapter.FillByTipo(this.sascrDataSet.tabSementes, tabBAdetDataGridView.Rows[e.RowIndex].Cells["TipoComboBoxColumn"].Value.ToString());
this.EspecieComboBoxColumn.DataSource = this.tabSementesBindingSource;
this.EspecieComboBoxColumn.DisplayMember = "Semente";
}
else
{
this.tabSementesTableAdapter.Fill(this.sascrDataSet.tabSementes);
this.EspecieComboBoxColumn.DataSource = this.tabSementesBindingSource;
this.EspecieComboBoxColumn.DisplayMember = "Semente";
}
}
Thanks in advance,
JC Carmo
|
|
|
|
|
Hello everyone,
Here's the scenario: I have three windows forms (frmMain, frmClients, frmOrders).
There's a button on frmClients that opens frmOrders.
Now, the question is: What's the code on frmClients to define that the frmOrders' MDIParent is frmMain?
Thank you very much for your time and help,
JC Carmo.
|
|
|
|
|
hi,if you declare frmOrder's MDiparent as frmmain,
then you cannot show frmOrder just like that.
you have to show the mdiparent of the formorder and then show formorder.
the code inside the button will be like
Order frm = new Order ();
FrmMain frmMain = new FrmMain();
frmMain.Show();
frm.MdiParent = frmMain;
frm.Show();
but infrmmain, the IsMDIContainer property should be set to true.
try this.
all the best.
those who win are those who believe they can
|
|
|
|
|
Hi,
u can simply write
frmOrders.MDIParent = this.MDIParent;
Hope that works for u
Regards,
Pramod
|
|
|
|
|
I am having trouble finding anything on this topic. I have a System.Windows.Forms.WebBrowser control on my windows form. In it there are some links. When the user clicks a link I want it to fire an event back in the windows form. Any help on how to do this would be appreciated.
Thanks
|
|
|
|
|
I'm creating a program that I need the context menu to show up automatically on load. I tried contextMenuStrip1.Show(this, 5, 5);, but it hides right away. Is there anyway that I can make it stay open until the mouse moves away from it or clicks away?
JGA
|
|
|
|
|
try this
ContextMenu menu = new ContextMenu();
MenuItem item = new MenuItem("test");
menu.MenuItems.Add(item);
menu.Show(this,new Point(10,10));
those who win are those who believe they can
|
|
|
|
|
Looks like that works for ContextMenu, but not for ContextMenuStrip. Any ideas?
|
|
|
|
|
Ok My problem is i don't know how to make a form modal. I know how to show them modelessly with Show() but as far as displaying them as modal im lost.
|
|
|
|
|
|
.ShowDialog() is what you're looking for. You can even get a return value (DialogResult) if you set it up right.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How would I display thimbnail images in a DataList control for a photo ablum?
|
|
|
|
|
|
Please don't 'advertise' your article here, it will probably result in it getting some 1 votes, and generally annoy people.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'm so so sorry
i really didn't mean it
Ahmad Shaban
|
|
|
|
|
LOL - my son tells me he 'didn't mean it', when he plainly did. However, I'm glad you deleted your post, you will definately find that posting ads anywhere except via placing an ad with the site will not result in anything positive for you.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I need to create an application that must be able to load the definition of a C# Windows Forms o User Control and show it properly in a windows forms just like the .NET IDE Designer does. Then the user can select controls and setup some properties.
How can I do this? Using reflection or what?
I appreciate any help or guidance.
FJ
|
|
|
|
|
You can check out the Microsoft Knowledge Base Article #813808[^].
Oh, and I really like your music. <smile />
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
You should have made him sing "The Wall" for us first before helping him.
|
|
|
|
|
You are so right.
If you don't eat your meat, you can't have any pudding! How can you have any pudding if you don’t eat your meat?
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|