|
If the 'TabAlignment' of a 'tabControl' is set to 'Left', the Controls headers text is aligned vertical.
Can anybody please introduce me to a way to realign (or rotate) the tabs header text so its displayed horizontal, while the headers still are on the left of the control?
Thanks in advance
-Soo
|
|
|
|
|
|
My question is actually in the subject. I'm tring to stop execution of code until webbrowser reloads the page, but the point is that most of it is coming in the background using AJAX httprequests so browser's DocumentCompleted event is raised to early while most of the document is still on the flight. How can I achieve the same effect as in mentioned event when AJAX stuff needs to be taken into consideration? should i monitor for net requests and responses coming in and out? it seems really complicated. Anybody has some idea?
|
|
|
|
|
completely no ideas? for now i made a timer but it assumes that quality of a connection is fine and has a constant interval which is not good and fails sometimes ..
|
|
|
|
|
When declaring:
[DllImport("kernel32.dll")]
public static extern int OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
It dosnt seem to matter what argument datatypes you use, for instance, this works aswell:
[DllImport("kernel32.dll")]
public static extern UInt32 OpenProcess(uint dwDesiredAccess, uint bInheritHandle, Int32 dwProcessId);
Question 1:
What should you think of when declaring imported functions? Should you try to match the c/c++ datatype to its c# datatype couterpart? (For instance, for c++ int, c# Int32). Or does it not matter?
Question 2:
Arguments that are pointers. I dont quite understand how IntPtr etc works since im quite new to c#. But if a function has a parameter that is a pointer (int* return_val for instance. Should you use a IntPtr for that? Or an unsafe c# pointer?
Question 3:
Arguments that are typedef'ed types, for instance handles that are a c++ (void*). Should you use c# unsafe void*? Or is an int just as fine? Are there any rules for this? For instance, HWND is a UInt32 or something like that..
Question 4:
The "out" parameter, should it be used for c++ pointers and references that returns values (non const)?
Thanks.
|
|
|
|
|
Others might give you a more complete answer, but I usually end up here[^] for interop stuff.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"I haven't spoken to my wife now for 48 hours. I don't like to interrupt her.
|
|
|
|
|
Hi,
Q1.
parameter type does not have to be exact, so you can e.g. mix int, uint, Int32 (anything
that is a 32-bit integer). Be careful with long (64-bit in C#, 32-bit in native C), and
use some int type when native is bool.
Q2.
pointers to basic types (such as int*) just need a ref keyword
read-only string is just string
writeable string buffer is StringBuilder with sufficient initial capacity
pointers to a composite type are more complex; either:
- specify the correct type and hope the default marshalling will work correctly for you;
- specify the correct type and add marshalling attributes as appropriate (complex stuff!);
- or specify an IntPtr, but then all you get is the pointer value, so you still must solve
the marshalling; typically you would use Marshal.PtrToStructure, PtrToStringAnsi, etc.
Warning: IntPtr is 4B or 8B depending on OS; you must use IntPtr for all Windows handles.
Q3.
I never use unsafe or void*. I prefer to use same things as in Q2.
Q4.
Use out or ref keyword for value types (int, struct) that need a pointer so the native
code can change the value.
In general, if you are in charge of both sides, keep the interface simple; I prefer to:
- work with ints and strings, occasionally a struct containing ints;
- avoid structs/classes containing other classes (including strings);
- allocate memory in managed code, not have native code create stuff and return a pointer.
Warning: if you must pass a pointer from managed to unmanaged and the marshalling does not
make clear it is a pointer (it would know with string, StringBuilder, etc. but not with
IntPtr), then you must use the GCHandle class and pin the object.
Final comment: I tend to experiment with P/Invoke and put a lot of logging statements
at both managed and unmanaged sides (the first function I implement is logging a string
from unmanaged to managed world, so I can collect and display (Console.WriteLine, ListBox...)
logging from both sides on the managed side. That way you can easily see where things start
to go wrong.(This takes a delegate as a function pointer, you did not ask that yet!).
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi all,
we have a table in sql server database.
We are using a data grid view control in our c# application.
How to retrieve and display a single record from the data base into the data grid view control.
Please suggest us at the earliest.
Regards,
Priya
|
|
|
|
|
I don't really understand the question. If you want to retrieve one record from the database, change your sql or stored procedure so that only one record is retrieved.
Wal
http://www.waleedeissa.com
|
|
|
|
|
Thanks for the response......
using datasource, dataset programatically in c# i want to retrieve the record from the sqlserver.
First I established the connection by connection string....
After that there is a problem in binding the data to the datagridview control.
Please suggest.
regards,
Priya
|
|
|
|
|
May I ask why you want to make it programamtically? DataSource controls weren't really meant to be used like that, they were created to make you write less code. BTW, what data source are you using, sqldatasource, objectdatasource ..etc? There're a lot of ways to retrieve data from a database, either by writing code, using a TableAdapter, using SqlDataSource .. etc, what exactly do you want to do?
Wal
http://www.waleedeissa.com
|
|
|
|
|
System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(SQLQuery,ConnectionString);
DataSet ds = new DataSet();
da.Fill(ds);
now bind your datagrid view with your dataset's table
dataGridView1.DataSource = ds.Tables[0].DefaultView;
Note: write a SQLQuery that will return only those record that u want to show on grid
|
|
|
|
|
can sum1 plz suggest me sum website 4m whr 2 dwnload new namespaces of visual studio 2005? pls se4nd me the links...
|
|
|
|
|
namespaces are not downloaded! are you talking about assemblies?
Wal
http://www.waleedeissa.com
|
|
|
|
|
You mean the .NET Framework 2.0? Just type it on google.
And please use regular English instead of that garbage.
|
|
|
|
|
System.Text.Spk
Oh...wait...that's obsolete now as nobody understood it.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"I haven't spoken to my wife now for 48 hours. I don't like to interrupt her.
|
|
|
|
|
What kind of language is that?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
but where are this messages stored? in one textbox? so how will user decide what is the name of file and which part of textbox text is to save?
or you simply want to save all the text from textbox but choose the file?
if so, make second textbox in which user will write the filename and save file like this:
StreamWriter msgStreamWriter = new StreamWriter(textBoxFileName.Text+".txt"); //with some validation if user written ".txt" or not
msgStreamWriter.WriteLine(textBox1.Text);
msgStreamWriter.Close();
if it is not a solution answer firts question
|
|
|
|
|
I am using a 3rd party library and tried to call a collection object. Worked fine in VB.NET but not in c#. in c# it asks to give an argument.Checking the definition in OBJECT browser, i found following:
VB.net:
Public Overridable Function Sessions(Optional ByVal item As Object = Nothing) As Object<br />
Member of: RepServerLib.IRepServer
c#:
public abstract new System.Object Sessions ( System.Object item )<br />
Member of RepServerLib.IRepServer
what the heck? why can't I use argument as OPTIONAL in c#? it drives me crazy. why is it not overridable in c#?
|
|
|
|
|
Hey don't take VBs abuse of good practice out on C#.
In pure OO terms, the VB version should actually be converted into 2 methods which would correspond to the following in C#:
public abstract object Sessions ()
{
return Sessions(null);
}
public abstract object Sessions(object item)
{
} The VB version is just syntactic sugar, and it does place some restrictions on VB code. Take this example:
Public Overridable Function Sessions() As Object
Public Overridable Function Sessions(Optional ByVal item As Object = Nothing) As Object Think about what would happen if you tried to call the no-parameter Sessions method. Not good is it?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
the issue is that the "Sesion" method returns a Collection list oBject. in VB.net, i can use "Count" method while count is alien for C#.
can you please tell em what should I do?
|
|
|
|
|
Cast the returned object to a collection, and you have the Count property available. The issue here though is that the Session should explicitly return a Collection if that is what is being returned. It shouldn't return an object and then rely on you to cast the object. Apart from anything else, this is going to result in unnecessary boxing/unboxing on this object.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Adnan Siddiqi wrote: why can't I use argument as OPTIONAL in c#? it drives me crazy. why is it not overridable in c#?
Because C# doesn't support optional parameters.
Cheers,
विक्रम
Be yourself, no matter what they say.
- Sting, Englishman in New York.
|
|
|
|
|
Hi there,
Is it possible to zip Files using C#?
eg,
I populate my listbox with files from my c drive using file uploader. The I want to take all those files amd Zip them into one Zip file then save them.
How can I do that?
|
|
|
|
|
This[^] article might help you with this. Alternatively, take a look at the SharpZipLib project.
Deja View - the feeling that you've seen this post before.
|
|
|
|