|
When you say "Service" do you mean that your C# program is running as a Windows Service? That's my assumption here, and yes it's possible. Whether or not it's advisable is another matter.
Now when I say "possible" I mean that the code will compile and build, and the .exe can be installed as a Windows Service and run. Often times one of the main reasons to develop a solution to run as a Windows Service is so that it can run even when no user is logged in to the computer. Now if that's the case, and the code finds it way down the path to where the MessageBox is .Show()'n, I don't know what will happen. Maybe nothing. Maybe it's displayed and causes the Service to stop executing until the nonexistent user clicks the unseen "OK" button.
Of course you could try it and see what happens. If you do, post your results here so everyone can know, too. Then try to find out if a tree falls in the forest....
BDF
|
|
|
|
|
If you need more information on the code...
//Method for converting a structure or object into a byte[]
public static byte[] RawSerialize(object anything)
{
int rawsize = Marshal.SizeOf(anything);
IntPtr buffer = Marshal.AllocHGlobal(rawsize);
Marshal.StructureToPtr(anything, buffer, false);
byte[] rawdatas = new byte[rawsize];
Marshal.Copy(buffer, rawdatas, 0, rawsize);
Marshal.FreeHGlobal(buffer);
return rawdatas;
}
//Method for converting a raw byte[] from a binaryReader stream to the original structure
public static object RawDeserialize(byte[] rawdatas, Type anytype)
{
int rawsize = Marshal.SizeOf(anytype);
if (rawsize > rawdatas.Length)
return null;
IntPtr buffer = Marshal.AllocHGlobal(rawsize);
Marshal.Copy(rawdatas, 0, buffer, rawsize);
object retobj = (Word)Marshal.PtrToStructure(buffer, anytype);
Marshal.FreeHGlobal(buffer);
return retobj;
}
These are the methods I use to convert to byte[] and back to my struct.
|
|
|
|
|
The structure contains a Hashtable. So it wont be possible to get the size of the structure by Marshal.SizeOf(anything) . Hence you wont be able to convert it to byte array using the above method.
jblouir wrote: public Hashtable htWord;
I am not sure whether it is recommended to use Hashtables/Collection classes in a struct.
*jaans
|
|
|
|
|
Ok,
So if I can figure how to store the same data in say...
a string[]
then ill be fine.
This makes things a bit tricky, I guess ill have to use the hashtable storage outside of the struct, then convert it to a string[] and an int[] and I can pull the values out based on index since I will know that string[1]'s value is int[1].
|
|
|
|
|
This didnt work, I change the hashtable to an int[] and it it threw another error.
TypeLoadException was unhandled
'System.Int32[110]' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' has too many dimensions.
|
|
|
|
|
SafeArrayTypeMismatchException was unhandled
'System.Int32[110]' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' has too many dimensions.
This occurs when I change the int[500] to int[50] since the last error sounding like there was too much data
|
|
|
|
|
I managed to get it to work finally, I changed the int[] to just a single int and I was able to load the data after I closed the program. This leaves me with a serious problem though, how am I going to load billions of entries without using some sort of organised format.
sigh..
|
|
|
|
|
In RowDataBound event of GridView the DataControlRowState.Edit
will trigger only alternatively.
If we are binding the column with a RadioButtonList,only alternate columns will only get binded.Is there any solution for this.
Regards
Bino
http://www.technix.co.nr
|
|
|
|
|
private void dgContacts_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
DataGridItem item = e.Item;
if (item.ItemType == ListItemType.AlternatingItem ||
item.ItemType == ListItemType.Item)
{
if ((e.Item.ItemIndex % 2) != 0)
{
LinkButton editButton = item.Cells[0].Controls[0] as LinkButton;
if (editButton != null && editButton.CommandName == "Edit")
{
editButton.Visible = false;
}
}
}
}
Never Think That You Have Failed Instead Always Think That u hav Better Chance Next Time...
|
|
|
|
|
we need to check both conditions (e.Row.Rowstate & DataControlRowSatate)>0
now it will work fine
www.codepal.co.nr
Regards
Bino
http://www.codepal.co.nr
|
|
|
|
|
Hi All,
I am facing problem with the text box whose scrollbars property is enabled to "both".
The Problem is when i retrieve data from a file and show its content in the textbox above specified, I allow the user to type and I have written a small module which when user types "enter" key the format(that is number of tabs or spaces) present in the previous line will be applied to the new line created.
To say it in simple words it is little like the c# programming environment regarding the paragraph indentations it provides to us when we type enter key.
Since I wanted to add text in the textbox in any place where user wish, i am retrieving the text and doing my operations and i put the updated one back to the textbox.
In the above case when data is too large so the scrollbar is active,since i am adding the text in the textbox, the scrollbar is showing the first position though the cursor is blinking in the nextpage.
when I attempt to write it scrollbar moves and it is showing the place where cursor is moving,the moment i type enter it is doing the same i told above. so it is giving a flickering effect. It is annoying a lot.
I had used richtextbox and all those suspendlayout and resumelayout.
Here is my code
\\ code
richTextBox1.SuspendLayout();
\\ gets the current position
iPosition = richTextBox1.SelectionStart;
\\ finds the format of the previous line and stores that in formatpattern string
FormatPattern = FindFormatPattern(richTextBox1.Text, iPosition - 2);
\\ here am adding it in the textbox
richTextBox1.Text = richTextBox1.Text.Insert(iPosition,FormatPattern);
\\ setting the current position
richTextBox1.Select(iPosition + FormatPattern.Length, 0);
richTextBox1.ResumeLayout(true);
\\ code ends
Thanks In Advance
kandy
kandy
|
|
|
|
|
Hello Friends,
there is an mdi child form(say form1) and a non-mdi form( say form2). in form1,a label and a button exists. on button click event i opened form2. in form2 there is a button. on button click event of form2 i want to change the label.text value
of form1. how will i do it. if anyone have solution, please reply me.
i solved this problem when both form are simple form on form1_activated event using some condition.
Thanks,
Mukesh
|
|
|
|
|
This[^] article is a good place to start.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello Mr. O'Hanlon
Thanks for reply.but,that is not the answer of my question.
my question is ---- there is an mdi parent form(say form1) and an mdi child form(say form2) and a non-mdi form(say form3).on form1 a button control(say 'show form2')and on form2, a label control and a button control(say 'show form3') and on form3, a button control(say 'reflect changes the label value of form2') exist.
when application executes.form1 is loaded. when click on button(say 'show form2'),its mdi child (form2) shows and when click on button of form2, a non-mdi form(form3 - called simple form) show. now i want to change the label control'value of form2 on form3'button click event.
i solved this type of problem on form1_activated event using some condition,if both form (form2 and form3) are non mdi form.
on form2 initialize the variable---> public static string active="1";
form2_activated event
----------------------
if(active!="1")
{
label1.text="ramu";
active="1";
}
form3_button_click event
-------------------------
form2.active="2";
this.close();
but this concept does not affect the form2's label control,when form2 is mdi child form.
so, pls reply. i am waiting for your answer.
Thanks,
mukesh
|
|
|
|
|
Hai Everybody,
I am having a list view, in that i have assigned a context menu strip and it has to be displayed only when the items are clicked.
If I am clicking on the columns also it is displaying the same menu.
How to protect this?
Then I want to display another menu when the columns are clicked.
Can any one tell me suggestion to resolve this?
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
Hi all, I am having problems adding controls to invisible panels. Making the long story short, if the panel has its property Visible set to false when I add the controls, they inherit that value. The problem is that when I set the panel to visible, those children are not shown and their property is still set to false.
Is this the correct behaviour, or am I doing something wrong? I will provide more details if needed.
Thank you,
Alessandro
|
|
|
|
|
cignox1 wrote: I will provide more details if needed
yes
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
|
|
|
|
|
Well, which kind of informations dou you need?
Something more:
I have a usercontrol that contains two panels. One of them is a tablelayoutpanel that contains dozens othe customcontrols. If I add these controls to the usercontrol when this is invisible, then they are also invisible. My problem is that when I put the usercontrol back to visible again, the two panels are displayed, but those controls are not. The only way I've found to make them visible is with the usercontrol visible, wich is not always desiderable in our project (it sould switch from visible to invisible on demand, without affecting the creation of the contained items).
I hope that this makes my problem easier to solve.
Thank you
|
|
|
|
|
Hi,
AFAIK Controls added to a Container don't inherit its Visible state, but the invisible
Container just does not invoke their Paint handlers.
If your UserControl behaves differently, then something in its code must do that;
Controls added to it should not copy its Visible property. I would call it a bug in the
UserControl, so that is where it must be fixed.
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
|
|
|
|
|
Hello,
When you change the control to visible, maybe also get it to repaint itself.
control1.Visible = true;
control1.Invalidate();
Probably you've already tried that. Oh well, just a thought.
BDF
|
|
|
|
|
Thank you, but I've already tried that. My problem is that when I add the controls to my panel when this is not visible, all the controls (wich are complex and thus formed by many controls) are created with Visible = false. This prevents them to be shown when I put the parent panel to visible.
|
|
|
|
|
cignox1 wrote: created with Visible = false
Aha! That's interesting. Not what I (nor Luc) would have expected. Since you are a few time zone ahead of me, you may have tried this already, too, but here goes.
My assumptions:
System.Windows.Forms.Panel tablelayoutpanel;
Your custom controls derive from System.Windows.Forms.UserControl
Either you or the designer do something like
tablelayoutpanel.Controls.Add(this.customControl2);
You could iterate the custom controls making them visible:
tablelayoutpanel.Visible = true;
foreach (Control c in tablelayoutpanel.Controls)
{
c.Visible = true;
}
BDF
|
|
|
|
|
Hi
I have 3 columns in my table. They are Yes\No filelds. If the row is Yes i want to take the header name of the column.in the below example if morning is yes i want to take Morning in datagrid
eg: if
Morning Evening Afternoon
Yes No YES
Yes Yes No
No Yes Yes
in the above example in first row Morning and Afternoon is True.
I want to retieve this to a Datagrid column Named Session.. i want to retrieve the above data to Session column
. in the case of first row i want to show like this in datagrid column
Session
Morning, Evening
Please help me to write Query and code
|
|
|
|
|
You might want to rephrase what you are trying to accomplish.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hy
I have a RichTextBox and I typing words separated with SPACE. I want to set different color for each word typed. Can anybody tell me how can I do that or give me an short example.
Thanks
|
|
|
|