|
Hello
One of the main ideas of C# -if not the main- is being managed by the garbage collector. That's why they call it a managed code -while there is an unmanaged code-. This task is quite advanced and is concerned with memory locations. Even then you'd have to store the memory location -otherwise known as pointer- somewhere to access the value.
You still can do something similar to that in C# with reference type only using WeakReference class. Revise it in your MSDN
Yet again what's exactly your point? Sometimes something that's possible is not always the best solution for a matter!! I'm sure there is a better approach to solve your problem -if it's not a mere programming challenge of some sort-
Regards
|
|
|
|
|
Hi friends,
Please tell me while converting C# gridview to excel how to autofit the columns in excel. Please Help Me.
Thanks & Regards
Prya
|
|
|
|
|
As far as I know, you can select all cells in the gridview and Ctrl+C, Ctrl+V them to Excel.
So nothing special there
WM.
What about weapons of mass-construction?
|
|
|
|
|
Hello
aaraaayen wrote: how to autofit the columns in excel
Do you want to do this in the code -ie programmatically- or just like WilliamM told you??
Besides, what does "autofitting" have to do with C# forum?!!
Regards
|
|
|
|
|
i need to do by programmatically.
Prya
|
|
|
|
|
Hello
What do you mean by "autofit columns"? Do you mean resizing the width of the column to fit the content? You want to write an application to do this inside Excel??!! It's quite strange!!!
Also another point. There are many ways to convert the data in a GridView to Exce format. What's your way in doing it? -If you think it's relevant to the issue at hand-
I think I need more details on exactly what you are planning to do. Maybe I could assist you more.
Regards
|
|
|
|
|
Usually I'm using StreamWriter to write the data in CSV file and import it using Excel.
I always use semicolon as delimiter.
|
|
|
|
|
i have a .h file like below.
how can i use it in C#?
//---------------------------------------------------------------
// AVEControl.h: interface for the AVEControl class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_AVECONTROL_H__4E171B4B_A11B_49F1_B41C_5F4A31B5CF08__INCLUDED_)
#define AFX_AVECONTROL_H__4E171B4B_A11B_49F1_B41C_5F4A31B5CF08__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifdef DEVICECONTROL_EXPORTS
#define DEVICECONTROL_API __declspec(dllexport)
#else
#define DEVICECONTROL_API __declspec(dllimport)
#endif
typedef HRESULT (*AVECALLBACK) (PBYTE pbData, LONG lDataLength);
#define E_DEVICE_NOT_READY 0xB0004001L
class DEVICECONTROL_API AVEControl
{
public:
HRESULT StartRecordWithoutPreview(HWND hWndCap, CString FileName, __int64 pFileLength, UINT pFileMessage, BOOL pShowSetting = TRUE);
HRESULT StartRecordWithPreview(HWND hWndCap, RECT rc, CString FileName, __int64 pFileLength, UINT pFileMessage, BOOL pShowSetting = TRUE);
HRESULT StartPreview(HWND hWndCap, RECT rc);
HRESULT SetVideoClippingWindow(HWND hwnd);
HRESULT SetCallback(AVECALLBACK Callback);
HRESULT GetVideoStatus(PUCHAR pSta);
HRESULT SetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect);
void GetCurrentImage(CString BmpFileFullName);
BOOL IsGraphRunning(void);
HRESULT StopGraph(void);
HRESULT ApplySettings(CString IniFileFullName);
HRESULT SetVideoProcAmp(long Property, long Value);
HRESULT GetVideoProcAmp(long Property, long* Value);
HRESULT GetEvent(long* EventCode, LONG_PTR* Param1, LONG_PTR* Param2, long msTimeout);
HRESULT SetNotifyWindow(OAHWND hwnd, long lMsg, LONG_PTR lInstanceData);
HRESULT InitDeviceControl(void);
AVEControl();
virtual ~AVEControl();
};
#endif // !defined(AFX_AVECONTROL_H__4E171B4B_A11B_49F1_B41C_5F4A31B5CF08__INCLUDED_)
|
|
|
|
|
you can try to create a DLL using the C++ class. After creating the DLL it's easier to use in c# with [DllImport] command. In c# char* becomes string byte* becomes byte[] and if you pass a value using reference like in your class "long* Value", use "ref log Value".
Hope it helps
Do your best to be the best
|
|
|
|
|
the Question is not the data type.
We can noticed that a class have been defined as below:
{
class DEVICECONTROL_API AVEControl
}
in the head file,
all the functions is defined in the class.
so if i use [DllImport] to define the function in C#,
when run it, an exception is found ,which message as "EntryPoint can not be found in DLL",
So I think the reason is that we cann't use the class from the unmanaged Dll
directly in C#,we have to build a wrapper use C++.net .
but How?
|
|
|
|
|
i created a c++ dll in .net using a code like this:
extern "C"
{
__declspec(dllexport) <method definition="">
{
//method body
}
__declspec(dllexport) <method definition="">
{
//method body
}
}
try it. maybe it will work for you too!
Do your best to be the best
|
|
|
|
|
thank you for your answer.
but I cann't do it.
because the DLL is already exist.
it was from a video capturer SDK.
the head file is defined as in the article.
and all functions have been defined in a class.
if i use [DlImport],compile is right, but when i run, an exception shown with"can not found the entrypoint from .dll".
i think the trouble is the class defination.
so i want to know how to use the class from the dll.
|
|
|
|
|
When a user right-clicks to open a context menu, most native Win32 apps allow the user to then also right-click on a context menu item to choose it.
I am writing a desktop app using WinForms on .NET 1.1. Unfortunately, System.Windows.Forms.MenuItem's Click event only get raised when the user left-clicks a context menu item. This makes my WinForms app feel clunky compared to native Win32 apps.
Is there a workaround to allow WinForms context menu items to be selected with a right-click?
thanks!
chris
-- modified at 21:07 Thursday 20th July, 2006
|
|
|
|
|
|
Hello
Well this right click issue is not a major draw back in WinForms -I think-. Yet you can still do it in C#.
Handle the Click event in your menu, and call a method to do the job from there. Then handle the MouseUp event in your MenuItem, check if(e.Button == MouseButtons.Right), and call the same method.
Regards
|
|
|
|
|
I finished a web site using Visual Studio 2005 ( ASP.NET ) and C# language.
In the Visual Studio internal server, it works perfectly, however after transferring the “SI” folder ( that contains the web site pages ) inside the “C:\inetpub\wwwroot”, and I typed its URL address in the browser, http://pegasus/SI/default.aspx, I get this error message:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Server Error in '/SI' Application.
--------------------------------------------------------------------------------
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: An error occurred loading a configuration file: Failed to start monitoring changes to 'c:\inetpub\wwwroot\web.config' because access is denied.
Source Error:
[No relevant source lines]
Source File: c:\inetpub\wwwroot\web.config Line: 0
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The strange thing is that there is no "web.config" file inside "wwwroot" folder.
How can I fix this problem and make the web site run inside IIS ?
( My OS is Windows XP )
|
|
|
|
|
Hy,
Try creating a virtual folder in IIS and then copy the site in that folder.The folder is located in wwwroot
Do your best to be the best
|
|
|
|
|
Hi
I already have done it but I continue receiving the same error message.
|
|
|
|
|
Hi guys,
I have a picture box with a picture on an mdi form but the problem I am facing is to always having the picture box centered on the mdi form. If the mdi form is maximized than it automatically centers the picturebox and if the mdi form size is reduced than it automatically centers in reference to the mdi form.
Please help!!
sasa
|
|
|
|
|
If you want the picturebox always centred then (if you're only displaying a picture) then you can set the PictureDisplay (or some property along the same lines) to Centre which means the picture will always be displayed in the centre, then dock the PictureBox to Fill and voila.
Other options include handling / overriding the Resize event and using your own code to reposition the picture box as you want.
The Welsh will always support two teams: The Welsh, and anyone playing England
|
|
|
|
|
Could you please be a little more specific. I am a newbie in C#. Please
sasa
|
|
|
|
|
Ok, of the two alternatives you can
- Set the Dock property of the
PictureBox to DockStyle.Fill (or as in the properties window: Dock ). You can then set the BackgroundImage property of the PictureBox to what you want. If you want it centred in the middle of the window then set the BackgroundImageLayout property to ImageLayout.Centre . - Second method is more complex but basically if you handle the Resize event of the MdiForm. Go into the code-window and start typing:
protected override void OnResize...
Then the designer should fill in the rest of the method for you. This method is fired whenever the form is resized so in this you can perform some calculations to resize the PictureBox. E.g. a simple example would be (simulating what happens when Dock is set to Fill):
protected override void OnResize(EventArgs e)
{
pictureBox.Location = new Point(0, 0);
pictureBox.Size = this.Size;
} Hope that helps a bit.
The Welsh will always support two teams: The Welsh, and anyone playing England
|
|
|
|
|
tabControl1.TabPages.Insert(tabControl1.TabPages.Count, newtabpage);<br />
MessageBox.Show(Convert.ToString(tabControl1.TabPages.IndexOf(newtabpage)));
i use a breakpoint on the first line... and when i do, tabcontrol1.tabpages.count comes up as 5, therefor it should be inserting this new tabpage @ index 5... but the next line shows a messagebox, showing which index the tabpage i JUST added is at, and shows 0.
the visual output of this, is that it creates 2 tabpages one at index 0, or at the front or left side, and one at the back or right.
i don't understand how a single line of code could insert 2 tabpages...
because of the breakpoint and messagebox i don;t think the rest of the function is relevant but i'll post it anyways, because i really just want some help on this.
public void addatab(string title, string url, string tooltip)<br />
{<br />
TabPage newtabpage = blanktabpage;<br />
foreach (WebBrowser i in newtabpage.Controls)<br />
{<br />
i.Name = title;<br />
}<br />
newtabpage.Name = "tab" + title;<br />
newtabpage.Text = title;<br />
newtabpage.Tag = url;<br />
newtabpage.ToolTipText = tooltip;<br />
tabControl1.TabPages.Insert(tabControl1.TabPages.Count, newtabpage);<br />
MessageBox.Show(Convert.ToString(tabControl1.TabPages.IndexOf(newtabpage)));<br />
}
also i tried using .add first, and that produced the same thing... i used .insert so i could blatently point out the conundrum =P
i've had the problem posted on microsofts site... msdn or something like thatm, but didnt get a response for a month... and i posted on my university forum, but the one person who kept helping me out, appears to be taking a break from the forums... so i've finally came here, because i know this place has some notbad tutorials and such, it's gotta have some smart people
also while im waiting i'll look more indepth of what exactly insert and add does for collections, to see if i can get an awnser there.
FFXI ftw
beatmania IIDX ftw
Soccer ftw
|
|
|
|
|
Well the .Add method seems to work fine for me, although the .Insert doesn't but I'm sorry that I don't have more time to investigate at the moment, if anything crops up I'll let you know.
The Welsh will always support two teams: The Welsh, and anyone playing England
|
|
|
|
|
One thing I notice about your function is this line:
TabPage newtabpage = blanktabpage Where is blanktabpage initialized and created? The question is important because I think your code is not actually creating a new TabPage every time the function is called. The reason for this is that class types are reference types, which means that unless you actually have the new keyword in there, you are not creating another instance of the class in memory. I'm not completely sure I have this down properly (I may have been wrong in my explanation), but have a look at this article by Jon Skeet[^] on the distinction between reference types and value types.
What this means (I think) for your code is that newtabpage refers to an already existing TabPage in memory. Changes that you are making with the variable newtabpage are affecting what blanktabpage points to. I'm not sure that this will necessarily produce the effect you are describing, but it is a problem.
Try this instead: at the beginning of your addatab function, use the new keyword instead, like this:
TabPage newtabpage = new TabPage() Then set the properties of the tab page based on the properties of blanktabpage and see what happens when you call Add or Insert .
I'm fairly sure what I have said in this post is correct concerning reference types, but if I am wrong, I would welcome a correction from anyone who knows better.
Sincerely,
Alexander Wiseman
|
|
|
|