|
JoeRip wrote: Anybody know why Visual Studio / C# can't parse it the first way?
Because nothing in this statement indicates aButtons is a collection of Button s:
ArrayList aButtons = new ArrayList();
However, if you used generic collections, you could do:
List<Button> aButtons = new List<Button>();
...
aButtons[0].Enabled = true;
/ravi
|
|
|
|
|
JoeRip wrote: I never would have figured that out
"And that is why you failed in the cave." -- Yoda
|
|
|
|
|
I have updated my RichTextBox but i can't get it to redraw.
I have tried several ways but the only one that somewhat works is to SELECT the data that is being updated .. but that has the nauseating effect on the User of causing the entire RTB text to scroll ... bad bad bad.
(no human input is involved in updating the RTB ... 183 lines are updated in microseconds ... unless SELECT is used ... then it takes a second or so)
The RTB gets updated just great, but i can not get it to redraw.
Suggestions, please.
private void UpdateRemainingTimes()
{
for (int n = 0; n < numReminders; n++)
{
string remainingTimeStr = GetRemainingTimeString(remDate[n]);
int lineIndex = ReminderRTB.GetFirstCharIndexFromLine(n);
int indexToDDD = lineIndex + 16;
ReminderRTB.Text.Remove(indexToDDD,remainingTimeStr.Length); // delete old stuff
ReminderRTB.Text.Insert(indexToDDD, remainingTimeStr); // put in new stuff
}
ReminderRTB.Invalidate(); // ??? does not cause the control to be redrawn ???
}
|
|
|
|
|
Have you tried Refresh and Update methods ??, the Update method should do it.
|
|
|
|
|
yes, i tried:
ReminderRTB.Invalidate();
ReminderRTB.Refresh();
ReminderRTB.Update();
in many flavors and combinations ... lol
i am beginning to wonder if there might be some property i have inadvertantly set that would prevent the redraws.
|
|
|
|
|
I don't recall where I found this but it should solve both of you problems:
Private Const WM_SETREDRAW As Integer = &HB
Private Const WM_USER As Integer = &H400
Private Const EM_GETEVENTMASK As Integer = (WM_USER + 59)
Private Const EM_SETEVENTMASK As Integer = (WM_USER + 69)
Private Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal msg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As IntPtr) As IntPtr
' We want to suspend redrawing because we need to select each
' character in turn to determine its fonts. However, RichTextBox
' appears to be missing some properties to do this, so use API:
' Stops RichText redrawing:
richTextBox1.SuspendLayout()
SendMessage(richTextBox1.Handle, WM_SETREDRAW, 0, IntPtr.Zero)
' Stops RichText sending any events:
Dim eventMask As IntPtr = SendMessage( _
richTextBox1.Handle, EM_GETEVENTMASK, 0, IntPtr.Zero)
' Get the selection extent:
Dim selStart = richTextBox1.SelectionStart
Dim selEnd = richTextBox1.SelectionStart + richTextBox1.SelectionLength
... perform processing here ...
' Turn events back on again:
SendMessage(richTextBox1.Handle, EM_SETEVENTMASK, 0, eventMask)
' Select the correct range (we must do this with events on otherwise
' the scroll state is inconsistent):
richTextBox1.Select(selStart, selSize)
' Turn redraw back on again:
SendMessage(richTextBox1.Handle, WM_SETREDRAW, 1, IntPtr.Zero)
richTextBox1.ResumeLayout()
' Show changes
richTextBox1.Invalidate()
|
|
|
|
|
i am SOOOOOOO embarassed ... complete noobie mistake .. failed to assign the RTB:
adding "ReminderRTB.Text = " to the front of these statements resolved the problem. <<blush>>
ReminderRTB.Text.Remove(indexToDDD,remainingTimeStr.Length); // delete old stuff
ReminderRTB.Text.Insert(indexToDDD, remainingTimeStr); // put in new stuff
... but thanks for trying to help!
|
|
|
|
|
I am designing a windows service to communicate with an application that has been written. The objective is to be able to send a notification message from the application(written in C#), to the windows service(also being written in C#). Once the service has recieved the message and processed it, It would send a message back to the application specifying whether or not the process completed successfully. I have been scouring MSDN and code project for articles on this topic, but I haven't been able to find anything relevent. I have a feeling I am not using the correct keywords. Can anyone point me to an article? Thanks
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Well, I found some stuff on MSMQ. This looks like it's going to be my way to go. What do you guys think?
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
MSMQ is good if you need a reliable message passing system. This means that you cannot loose messages between the client and server (in either direction) if one of them is down. It usually is overkill for most things.
You need to look at creating a service that understands how to talk through the .NET remoting channels or use WCF. Using WCF is much simpler, but adds a dependency on .NET 3.0 or later.
|
|
|
|
|
Hi,
My application has a class CUser which represents a user. The application serializes the user object to XML like this:
CUser aUser = new CUser("firstname", "surname", "address");
XmlSerializer serializer = new XmlSerializer(typeof(CUser));
StreamWriter streamWriter = new StreamWriter("user.xml");
serializer.Serialize(streamWriter, aUser);
streamWriter.Close();
I've been asked to have the user details encrypted so people can't casually look at the user details. From the above I'd like to encrypt the XML strings as they're written to the file but is there an easy way of doing it? It seems that it would be convenient to have the data encrypted by the StreamWriter and then decrypted by a StreamReader . I'll need a password so how do I manage that within the application?
Thanks 
|
|
|
|
|
Hmm, you could serialize it into a memory stream, read out the stream into an array of bytes, ecrypt the bytes with one of the built in classes or whatever, then write the encrypted array to file. And of course if the data structure becomes to large to just dump into a memory stream, you could use a filestream and create a temporary file, just remember to delete the temp file.
That just seems a bit much effort to me but...
There's probably a simpler way, but ive never used xml with c#, and i have no idea whats there. Infact, i only ever used encryption once. 
|
|
|
|
|
There are classes in the Xml namespace that allow you to work with encrypted XML files. Look on MSDN for "Xml encryption".
|
|
|
|
|
Hi
I don't have something smart to say regarding XML encryption,
But i want to mention something else regarding XML Serialization.
when you are using the XmlSerializer in order to serialize XML it create temporary dll that contain the serialization logic code.
In my experience i saw that it is better to use a pre compiled serialization logic code in two dimension
1.performance
2.security
you can create pre compiled serialization logic code by using the sgen.exe tool
|
|
|
|
|
In my application, i start a new thread which waits for a connection from another machine:
TcpListener connect = new TcpListener(IPAddress.Any, 7777);
connect.Start();
Socket clientSocket = connect.AcceptSocket();
If it receives a connection it goes into a while loop and communicates with the other machine. And it closes when finished.
But, if i want to stop the thread before it's made a connection...
connect.AcceptSocket is blocking so...
and when i try to abort the thread nothing seems to happen.
-- modified at 11:55 Saturday 22nd September, 2007
Never mind, i made the TcpListener a class variable, and added a method that calls connect.Stop(); and flags that the thread should stop. Then everything works out.
|
|
|
|
|
Hello all,
I have a MA-620 USB Infrared Adapter. I'm trying to make a small application that will receive my Sony TV remote controller signals.
Is it possible? do I have the right hardware? All Infrared-C# articles I found were WinCE specific.
|
|
|
|
|
I want to get the Processor ID of CPU.
I have tried to use the sample in the code project.
I have tested the application in 5 dual core machine, but it is giving the same Processor ID for all
Can you please suggest me a way to get the ID for dual core processor machine (Intel(R) Pentium(R) D CPU 300 GHz).
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
M. J. Jaya Chitra wrote: I have tried to use the sample in the code project.
What sample or article was that? You might want to try the forum at the bottom of the particular article, which might alert the author, in turn the author might reply to you.
"Try asking what you want to know, rather than asking a question whose answer you know." - Christian Graus
|
|
|
|
|
Hi
In order to retrieve information regarding the current cpu you can use WMI
In this case i am using the Win32_Processor Class
http://msdn2.microsoft.com/en-us/library/Aa394373.aspx[^]
Try using the following code:
class Program
{
static void Main(string[] args)
{
ConnectionOptions conn = new ConnectionOptions();
conn.Impersonation = ImpersonationLevel.Impersonate;
ManagementScope scope = new ManagementScope(@"\\mymachine", conn);
ObjectQuery query = new ObjectQuery("Select * From Win32_Processor");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection coll = searcher.Get();
foreach (ManagementObject obj in coll)
{
Console.WriteLine(obj["UniqueId"].ToString());
}
}
}
|
|
|
|
|
i have a enum type with the following defination
enum enumCatalogExportStandard { CatccExportAsISO, CatccExportAsFGDC, CatccExportAsNative };
enumCatalogExportStandard ImportStandard ;
ImportStandard = enumCatalogImportStandard.CatccImportAsISO ;
ImportStandard is showing value as 1 instead of CatccExportAsISO how can i get the "CatccExportAsISO " instead of 1.
Please help me.
|
|
|
|
|
Please post which method do you use to visualize enumeration variable's value.
To obtain a text representation, try ImportStandard.ToString() method.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
i tried to display the value "ImportStandard.ToString() " using messagebox it returned 1 only.
can u please tell me some other alternative.
|
|
|
|
|
This is an alternative:
MessageBox.Show(Enum.GetName(typeof(enumCatalogExportStandard ), ImportStandard));
But... it is impossible. The code:
enum alph { A, B, C }
alph ph = alph.A;
MessageBox.Show(ph.ToString());
gives me "A"... Please post the full code.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
hi Gajatko,
i don't know why any alternative is not working in my m/c.
when i tried
MessageBox.Show(Enum.GetName(typeof(enumCatalogExportStandard ), ImportStandard));
gave me a null string as output.
i am sending the code snippets where ever i am using the enum related stuff in my code pls view.
public enum enumCatalogImportStandard { CatccImportAsISO, CatccImportAsFGDC, CatccImportAsNative };
enumCatalogImportStandard ImportStandard;
private void cmbTargetstd_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbTargetstd.SelectedItem.ToString() == "ISO")
ImportStandard = enumCatalogImportStandard.CatccImportAsISO ;
else if (cmbTargetstd.SelectedItem.ToString() == "FGDC")
ImportStandard = enumCatalogImportStandard.CatccImportAsFGDC ;
else if (cmbTargetstd.SelectedItem.ToString() == "Native")
ImportStandard = enumCatalogImportStandard.CatccImportAsNative;
}
private void btnApply_Click(object sender, EventArgs e)
{
CImportCatalogRecordService.ImportCatalogRecordService objImpRecService = new CImportCatalogRecordService.ImportCatalogRecordService();
//below statement returning number instead of string
objImpRecService.ImportStandard = ImportStandard;
objImpRecService.InputFileName = txtImportFolder.Text + "\\" + Rec;
objImpRecService.CatalogConnection = con;
objImpRecService.Execute(out MetadataID);
}
this is all my code Pls view.
|
|
|
|
|
nicolus wrote:
objImpRecService.ImportStandard = ImportStandard;
Of course it returns a number. Change it to:
objImpRecService.ImportStandard = ImportStandard.ToString();
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|