|
Hi,
How can i 'see' what check box(es) are selected in an if statement?
This is how i want it:
if(chkbx1.checked == true AndOr chkbx2.checked == true ....... AndOr chkbx10.checked == true)
Thanks in advance!
|
|
|
|
|
What is the AndOr operator supposed to do? The C# or operator || is non exclusive, which means that it's result is true if either operand is true or both operands are true.
|
|
|
|
|
Hi,
I want to check if non is selected or 1 or more.
Depending on which chkboxes are selected, its suppose to do something with all the code "behind" the selected boxes.
So || is what i need ha.
Ima try that.
Do you also happened to know how i can merge 2 .txt files into a new file?
Thanks in advance!
|
|
|
|
|
The shortest way:
string file1 = File.ReadAllText("file1.txt");
string file2 = File.ReadAllText("file2.txt");
File.WriteAllText("file3.txt", file1 + file2);
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
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
|
|
|
|