|
Hi Greeeg,
Thanks for your reply,
I meant in a new file.
So if i understand the way you did it. Than this is how it would be done to a new file (please do correct me if i'am wrong):
string file1 = File.ReadAllText("file1.txt");
string file2 = File.ReadAllText("file2.txt");
StreamWriter file3 = new StreamWriter("file3.txt", true);
file1.Write(file3);
file2.Write(file3);
|
|
|
|
|
See my previous post. I made a mistake and rewrote it
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
Hi,
Is there a way that I can programmatically resize the columns of a listview in report mode so all the text in the columns is visible when it comes up?
thanx
|
|
|
|
|
Hi!
Yes, you can set the column header's width to -1 or -2 so that it'll adjust to the maximum item width or the column heading width resp.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
|
how can i refresh SQLserver tables from C# using ado.net classes
|
|
|
|
|
Can you explain in more detail what you are trying to do?
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
hey guys
I am tring to implement a filter in a datagrid. I am using a datatable
which is the datasource for the grid.
I need to filter set of rows. i.e. from row 1 to row count. i need to
keep my row 0 intact, which is an option to add a new person.
textbox key up code looks like this:
string strRowFilter = String.Concat("Name LIKE '%", txtName.Text,
"%'");
dv.RowFilter = strRowFilter;
grdNames.DataSource = dv;
plz help
sunny
|
|
|
|
|
I've been given the task of upgrading an old VB6 application to C#, and I think I'm starting to go down for the third time.... (and yes I've been reading miriads of posts, but not getting it).
The old application used a dll which still needs to be called in the new c# application.
In the vb6 code, the dll function needed was declared like this:
Declare Sub neededFunciton Lib "UnmanagedDLL.dll" (ByRef nestedStruc As NESTED_STRUC_TYPE)
where....
Public Type NESTED_STRUC_TYPE
iNum1 As Long
fNum2(coniMaxSize) As Single
nextNestedStruc As NEXT_NESTED_STRUC_TYPE .
End Type
Public Type NEXT_NESTED_STRUC_TYPE
iAnotherNum1 As Long
fAnotherNum2(coniMaxSize) As Single
THIRDNestedStruc As THIRD_NESTED_STRUC_TYPE
End Type
Public Type THIRD_NESTED_STRUC_TYPE
fArray1(coniMaxSize) As Single
fArray2(coniMaxSize) As Single
fArray3(coniMaxSize) As Single
fArray4(coniMaxSize) As Single
End Type
Public Const coniMaxSize As Integer = 144
In C#, I created a class BigObject containing all that struct stuff and the declarations:
[DllImport(@"C:\WINDOWS\UnmanagedDLL.dll", EntryPoint = "NeededFunciton")]
internal static extern int neededFunciton(ref NESTED_STRUC_TYPE nestedStruc);
After reading some examples I included this:
[DllImport("kernel32.dll", SetLastError=true)]
public static extern IntPtr LoadLibrary(string dllToLoad);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool FreeLibrary(IntPtr hModule);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate BigObject MyDelegate(ref BigObject.NESTED_STRUC_TYPE nestedStruc);
internal int NeededFunciton(ref NESTED_STRUC_TYPE nestedStruc)
{
IntPtr pDll = LoadLibrary(@"C:\WINDOWS\UnmanagedDLL.dll");
if (pDll != IntPtr.Zero)
{
IntPtr pAddressOfFunctionToCall = GetProcAddress(pDll, "NeededFunciton");
if (pAddressOfFunctionToCall != IntPtr.Zero)
{
MyDelegate myDelegate = (MyDelegate)Marshal.GetDelegateForFunctionPointer(
pAddressOfFunctionToCall,
typeof(MyDelegate));
try
{
myDelegate(ref nestedStruc);
}
catch (Exception e)
{
}
}
}
return Convert.ToInt16 (FreeLibrary(pDll));
}
Finally, in another class, I try to call the NeededFunciton with the nestedStruc which has been prepopulated with data:
bigObject.NeededFunciton(ref nestedStruc);
I'm getting
FatalExecutionEngineError was detected
Message: The runtime has encountered a fatal error.
The address of the error was at 0x79f1c184, on thread 0x970. The error code is 0xc0000005.
This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code.
Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
OK, with all those nested strucs, I'm guessing I'm getting marshaling errors.
Can someone shoot me to a good site ref. or add a bit of insight that might kick start me again?
I'm afraid I have chronic brain cramp....
|
|
|
|
|
cpshadle wrote: good site ref
http://www.codeproject.com[^]
(Sorry, that was a bit harsh. Sorry I can't help at the moment but I'll take a look through when I get the chance).
|
|
|
|
|
|
If I create a Generic Dictionary<K,V> collection object and use my own custom class as the Key, do I have to override the Equals(object o) and GetHashCode() methods for my custom class?
I know I have to do this if I use the non-generic version of Dictionary, the HashTable class, according to MSDN documentation anyway, but I can't find anything about how this rule applies to the Generic Dictionary<K,V> collection type. I'm assuming not, but then how does the Dictionary hash the key internally?
Cheers!
Sunday Ironfoot
|
|
|
|
|
Never had to in my cases.
|
|
|
|
|
hi
i use vs2005 and i add "Applications.ico" to my Application resource. How to Create Icon object from resource as stream ??
i could create Image object from resource as stream. but could not create Icon object. how to create Icon object from resource as stream ??
thanks
|
|
|
|
|
Icon myIcon = new Icon(theStream);
|
|
|
|
|
hi
thanks for reply, but i did this work (like image object) and an error occured in this subject (Icon _icon = new Icon(_stream))
please give me an example for working correctly.
thanks...
|
|
|
|
|
Is the stream from a real icon stream? Or from an image stream?
|
|
|
|
|
ResourceManager res = new ResourceManager("MyNamespace.Properties.Resources", this.GetType().Assembly);
Icon myIcon = (System.Drawing.Icon)res.GetObject("MyIcon");
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
hi
thanks for reply but when i write this code and compile my app the following error shown me :
System.Resources.ResourceManager res = new System.Resources.ResourceManager("AmlakButtons.Properties.Resources", this.GetType().Assembly);
System.Drawing.Icon _icon = (System.Drawing.Icon)res.GetObject("PRINTERS11");
Error : Unable to cast object of type 'System.Drawing.Bitmap' to type 'System.Drawing.Icon'
|
|
|
|
|
I assumed that your resource was an Icon.
Try this:
ResourceManager res = new ResourceManager("AmlakButtons.Properties.Resources", this.GetType().Assembly);
Bitmap myBitmap = (System.Drawing.Bitmap)res.GetObject("PRINTERS11");
Icon _icon = Icon.FromHandle(myBitmap.GetHicon());
myBitmap.Dispose();
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Well this is my first reply in cp, so please correct me if i'm wrong
This works in vs2k3 so i guess it'll work in 2k5 as well.U can create a Bitmap from the stream, which can then be converted into an icon object.
Bitmap b = new Bitmap(System.IO.Stream);
Icon tempIcon = Icon.FromHandle(bmpTemp.GetHicon());//Hicon returns a handle to an icon which we use to create a temp icon.
obIcon = (Icon)tempIcon.Clone();
Win32API.DestroyIcon(tempIcon.Handle);//we have to create a temp icon and destroy it coz of some resource disposal probs.
|
|
|
|
|
I need Icon.FromHandle() method in Compact Framework but the FromHandle() method is not supported by the CF 1.0! So I searched a while and found an article at OpenNETCF.org[^] which did it:
The code worked fine with PPC2002 and WM2003 but not works under WM2005...
There seems to be a problem with the palette colors... The icon can be displayed but with wrong colors or transparency is a problem.
1. The SDF uses CreateDIBSection() with a BITMAPINFOHEADER parameter but MSDN and function prototype says that it is a BITMAPINFO.
2. P/invoked BITMAPINFOHEADER is missing biClrUsed and biClrImportant
3. Correcting issues 1+2 does not solve the problem. Very strange: If the application was launched using the debugger it works (icon displayed correctly). If launched without debugging (from within VS) the colors are not correct (black instead of transparency)
The debugger seems to initialize something wich causes this behaviour but of course the app should be able to display the icons correctly without a debugger
Thx for some help!
|
|
|
|
|
I'm populating a DataTable as follows:
******************************************
DataSet tempDS = new DataSet();
DataTable tempDT = new DataTable();
tempDT.Columns.Add("area");
tempDT.Columns.Add("meas");
tempDT.Columns.Add("date");
tempDT.Columns.Add("denLine");
tempDT.Columns.Add("iv");
tempDT.Columns.Add("dIndex");
tempDT.Columns.Add("mIndex");
for (int i = 0; i < temp_area.Length; i++)
{
DataRow tempDR = tempDT.NewRow();
tempDR.ItemArray = new object[] { temp_area[i], temp_Measurement[i], dateArray[i], denLine[i], tempIV[i], dIndex[i], mIndex[i]};
tempDT.Rows.Add(tempDR);
}
DataRow[] sortedRows = tempDT.Select("", "area");
*****************************************************
temp_area is the array which I wish to sort by and it contains integer data however using the above select routine to sort it does a string sort and so the integer 2789 will be sorted below 26789 in an ascending sort.
Lol I just thought of looking for an overloaded Columns.Add that would specify column type and found it. After typing all of this i'm going to still post in case someone else comes across the same problem. The solution is to change
tempDT.Columns.Add("area");
to
tempDT.Columns.Add("area", Type.GetType("System.Int32"));
bward
|
|
|
|
|
Specify the data types when you create the columns. All the columns that you create gets the data type string, so all the values that you put in the table will be converted to strings. Naturally they will also be sorted as strings.
---
b { font-weight: normal; }
|
|
|
|