|
If you're looking for getting the IP address from the TcpClient object, you have to kludge your way through. Something like this.
IPEndPoint GetEndPoint(TcpClient client)
{
Socket socket = (Socket)client.GetType().InvokeMember("Client", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetProperty, null, client, null);
return socket.RemoteEndPoint;
}
The above snippet uses reflection to get the socket instance associated with the TcpClient, because, for some reason, the API designers decided to make it non-public.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Is there a way to convert a string to date type?
Thank you
|
|
|
|
|
|
Hi all!
I've got a big problem with regular expression (I'm not very smart).
I have to select in a text all the c# multiline comments: /* ... */.
I use the following pattern:
\\/\\*.*\\*\\/
Note that I use the SingleLine option, so the dot means ALL chars.
that runs correcly only for the first occurence:
/* hello! */ is ok, but if there are two comments, like:
/* hello 1 */ some text here (with newlines) /* hello 2 */
the pattern selects all the text between the FIRST /* and the LAST */
I know the pattern is wrong, but I do not know any other statement...
Please help!
|
|
|
|
|
Regular expressions are greedy by standard, meaning that the expression .* will try to match as many characters as possible. To make it match as few characters as possible you have to make it non-greedy (lazy) by adding a question mark after it: .*?
Use this pattern:
@"/\*.*?\*/"
---
b { font-weight: normal; }
|
|
|
|
|
|
One big difference I've found between the VB6 RTF and the C# RTF is that the VB6 one has a Print() function. I expected to find an even better one in C#, but there's nothing there. Is there a way to print from a C# RTF short of making my own and basically defeating the whole purpose of having an inbuilt one? I want to be able to specify by page, too, if possible.
|
|
|
|
|
|
That actually worked suprisingly well. Thanks.
|
|
|
|
|
Is there a way to make a property in a propertygrid which opens up a form (sort of like browsing for an image), when a value is chosen from the form and the form closes i then get the chosen value in the property grid ?
|
|
|
|
|
|
Hi,
I am new to Asp.net, I am using the below code on a link-click event to add a row in a datatable and then bind it to a datagrid. But only the last row is visible in the datatable. May be bcoz I am creating a new table on the click. How to get all the values persist on postback???
My code is :
DataTable dt = new DataTable("Requirements");
DataColumn dc= dt.Columns.Add("RequirementId");
DataColumn dc1= dt.Columns.Add("RequirementName");
DataRow row=dt.NewRow();
row["RequirementId"] = "R0001";
row["RequirementName"] = "New Requirement";
dt.Rows.Add(row);
Thanks
dgRequirements.DataSource = new DataView(dt);
dgRequirements.DataBind();
|
|
|
|
|
Set the datagrid's EnableViewState property to true ,and then in the second postback ,access it using :
ViewState["Your DataGrid name"]
And then add the last row only to it.
OR
Create a DataTable object at the class level ,and add its value to the viewstate by the same way,and in the click event just :
DataRow row = myDataTable.NewRow();
row["RequirementId"] = "R0001";
row["RequirementName"] = "New Requirement";
myDataTable.Rows.Add(row);
|
|
|
|
|
hi...
Thx for the reply.
I defined DataTable object at class level.
then I put the below code in form-load
dt=new DataTable();
DataColumn dc= dt.Columns.Add("RequirementId");
DataColumn dc1= dt.Columns.Add("RequirementName");
dgRequirements.DataSource = new DataView(dt); /// datasource to grid
dgRequirements.DataBind();
ViewState["dt"]=dt;
And the Following code at link-click
dt=(DataTable)ViewState["dt"];
DataRow row=dt.NewRow();
row["RequirementId"] = r.RequirementId;
row["RequirementName"] = r.Description;
dt.Rows.Add(row);
ViewState["dt"]=dt;
But its not adding any row in the Datagrid...Whats wrong in the above code?
Thanks a lot.
|
|
|
|
|
You must check first if its a postback or not,
This may work :
Page_load()
{
if(!IsPostBack)
{
dt=new DataTable();
DataColumn dc= dt.Columns.Add("RequirementId");
DataColumn dc1= dt.Columns.Add("RequirementName");
}
else{
DataRow row=dt.NewRow();
row["RequirementId"] = r.RequirementId;
row["RequirementName"] = r.Description;
DataTable t = (DataTable)ViewState["dt"];
t.Rows.Add(row);
ViewState["dt"] = t;
}
}
|
|
|
|
|
|
Hi,
I am having various controls say... Estimated Start Date, Estimated End Date(both are text fields with date)
How can I perform these validations using Asp.net Validation Controls
1) If I input Estimated End Date, it is compulsory for me to input Estimated Start Date, other wise it can be left empty.
2) Estimated Start Date >= Todays date (if i input it)
Please Help me..
Thanks
|
|
|
|
|
Does anyone know how to create select all capabilities in a listview without using a right click menu or button? What i want is what you see on the web all the time. A little checkbox next to the text in the column header. I don't mind writing a new column header control but to have to create a completely owner drawn listview? That seems crazy.
Thanks
|
|
|
|
|
I'm developing a small text editor in c# that must have header and footer. The problem is when i load a rtf file with header and footer, they don't appear in the richtextbox. I tryed to change the margins, tryed to set a header footer with richtextbox.rtf = ... Does anyone knows the solution for this?
|
|
|
|
|
AFAIK, the RichTextBox class doesn't support headers and footers.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
AFAIK, thank's for reply me. About the richtextbox, i'm extendig the class to support a few features like tables, copy, paste, formating, print, etc... all this using windows api. There's no other solution to the solve problem?
|
|
|
|
|
Other than adding support for it yourself, not that I know of.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi all,
I've a question about Application.Run, which is supposed to start the main loop for receiving messages for windows.forms applications. What I want to do is hide the form on startup, which I do either with setting the Visibility property to false or calling Hide(); so far no problems with that. But when I start the loop with Application.Run(form); it makes the form visible. The thing is that it makes the form visible after calling the constructor so what's the proper way of starting a form with Application.Run(Form); which will be hidden? Any advice is appreaciated
Regards
|
|
|
|
|
In this form Load event just call :
Hide(); .
|
|
|
|
|
That doesn't work.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|