|
|
Hello,
I am beginning to write a custom combobox control. Right now it doesn't do anything special. I created a class that extends ComboBox:
public class TimeSelector : System.Windows.Forms.ComboBox
and in its constructor I call Populate:
public TimeSelector()
{
try
{
if(!DesignMode)
{
Populate();
}
}
catch(Exception ex_)
{
MessageBox.Show(ex_.Message);
}
}
where Populate is as follows:
private void Populate()
{
Items.Clear();
string[] times = new String[48];
DateTime dt = new DateTime(1,1,1,23,30,0,0);
for(int i = 0; i < 48; i++)
{
dt = dt.Add(new TimeSpan(0,30,0));
times[i] = dt.ToString("h:mm tt");
}
DataSource = times;
}
Now, when I run a form that contains this control, the combobox correctly contains all of the items that I populated it with. However, whenever I do anything to the control while I am looking at the form that contains it in design mode, it gets messed up.
Specifically, when I go back to look at InitializeComponent in the form's code, it seems to have added all of the times to the combobox thru a DataSource and then it manually adds each time to the combobox's Items collection right after that:
this.ts.DataSource = new string[] {
"12:00 AM",
"12:30 AM",
"1:00 AM",...
this.ts.Items.AddRange(new object[] {
"12:00 AM",
"12:30 AM",
"1:00 AM",...
This causes an error because you can't modify the combox's Items while it is data bound. And this happens no matter what I do while in design mode (if I move the control, set Enabled to false, whatever).
Can someone tell me what I am doing wrong?
Thanks,
-Flack
|
|
|
|
|
Hi all, I have a problem finding a way to hit test two regions. Found the
method IsVisible, but it doesn't work out well. Does somebody have a suggestion?
|
|
|
|
|
Hi!
Don't know if it will work, but you could try creating the intersection of the two regions (using Region.Intersect()) and then compare the result to an empty region (created with Region.MakeEmpty()).
Region.Equals is overloaded, so perhaps it will return true if you compare two empty regions.
If your two regions _do_ overlap, the intersection will not be empty and the comparison will return false. Otherwise, if your regions _don't_ overlap, you'll have an empty intersection and the comparison should return true.
I didn't try but it could work.
Regards,
mav
|
|
|
|
|
I've tried this, but the problem is that the overloaded Equals method requires a Graphics object. (Main problem is that I know very little about Graphics and Regions by the way). I can create a new Graphics object (from my parent form) using CreateGraphics, but this doesn't seem to work.
|
|
|
|
|
Hi
I want to do encryption with the .NET classes and then decrypt with a native c class to not be dependant on .NET on the decrypting side. For instance using dsCrypt available at:
http://freezip.cjb.net/freeware[^]
However I just cant manage to decode the message correctly, is just becomes junk. Has anyone expericance from doing a similar thing?
|
|
|
|
|
I am creating an application for a mobile device with pocket PC in C# manufacturer is Symbol . Can any body help me how can I get scanned barcode into my C# (windows) application .
Thanks
Learner always
|
|
|
|
|
hi
I want to save my database table contents in to CSV format using C# .
how can i do this.
This is very urgent plz reply ASAP.
Thanks in advance
Alok
|
|
|
|
|
A csv format replaces tabs with commas so if you can read your table then you can convert from datatable to csv as shown in following pseudo-code:
DataTable myTable = GetTableContents(tableName);<br />
StringBuilder sb = new StringBuilder();<br />
foreach (DataRow row in myTable.Rows){<br />
for (int colIndex = 0; colIndex < myTable.Columns.Count){<br />
if (colIndex != 0) sb.Append(",")<br />
sb.Append(row[colIndex].ToString());<br />
}<br />
sb.Append("\n");
}
|
|
|
|
|
Hi,
I'm new to .Net and very much need to know how I go about creating a server on a client PC that I can hook other applications into ?? I don't want to use remoting as its on the same client machine but I need to keep a stategull component that is instantiated by the first app to hook to it and avaialble to other apps to hook into ??
Thanks
Chubby..
|
|
|
|
|
One possibility is to use Sockets, and listen only on the 127.0.0.1 interface. But, that's a lot of manual work, developing a basic protocol for the communication and then the code to transfer and respond to whatever you send or receive.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Thanks John. I've decided to look at Remoting, got the simple one working (MSDN)....Will post another thread more approriate to my problems now. Thanks again.
Chubby..
|
|
|
|
|
I had a function in Invoke.dll
int __stdcall Invoke( const char *arglist[], int count );
to use it , I call it in c#
first declare:
[DllImport("Invoke.dll")]
static extern int Invoke( string[] arglist, int count );
then call it:
string[] arglist = "1, abc, xyz".Split(',');
for( int i = 0; i < arglist.Length; i++ )
{
arglist[i] = arglist[i].Trim();
}
try
{
Invoke( arglist, arglist.Length );
}
catch( Exception ex )
{
Console.WriteLine( "Invoke exception: {0}", ex.Message );
}
It works well, but if I use "1, ,xyz", then the string[] will have a "" string, this result a exception: The parameter is incorrect.
I want to know why, because it is sure sometime "" is a valid parameter.
++O++
/ \
hhmmdd
|
|
|
|
|
sorry, I found the problem not only "1, ,xyz", but also when I do follow:
string[] arglist = "1, ,xyz".Split(',');
for( int i = 0; i < arglist.Length; i++ )
{
arglist[i] = arglist[i].Trim();
}
++O++
/ \
|
|
|
|
|
I didn't really read your question, but from your subject line it looks like you want to know what .net type you want to use for a unmanaged char[]. I suggest a StringBuilder with the out modifier.
/\ |_ E X E GG
|
|
|
|
|
no, not unmanaged char[], it is unmanaged const char *[]
|
|
|
|
|
oh, I don't know then. Sorry.
/\ |_ E X E GG
|
|
|
|
|
Is anyone aware of a control for entering TimeSpans ? I found this one[^], but unfortunately this is for ASP.NET not for Windows Forms.
It doesn't matter whether for .NET 1.1 or 2.0.
I already thought about using DateTimePicker in time-only-mode, but I also want to be able to enter days and this is not possible with the DateTimePicker .
Maybe some masked TextBox control with a certain mask?
Any ideas?
--
Affordable Windows-based CMS for only 99 €: try www.zeta-producer.com for free!
|
|
|
|
|
Could you perhaps use two DateTimePickers to specify start and end time? That way you could specify an arbitrary duration...
Just a thought,
mav
|
|
|
|
|
Hello,
I've added some code to use the macromedia flash player (flash.ocx) to my windows forms application.
If the flash player is not installed on my clients pc it will crash the application.
How can I programmatically determine if the flash player is already installed and execute the flash code based on the condition if the flash player is installed or not.
thx!
|
|
|
|
|
At what point does your application crash? If it is after you've executed some of your own code, you ought to be able to use try/catch or other error handling mechanisms built into .NET to catch whatever error is causing your crash. At that point, you should be able to detect that the player isn't present.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Yes, I know the try catch is a possible solution.
That's also how I implemented it at this time to avoid the possible crash of the application.
(application crashes when I call the code to play the flash swf file)
I don't like relying on the try catch statement.
I think it should be possible to determine if the flash player is installed and only execute the code to play the flash file if the flash player is installed. (otherwise display image)
|
|
|
|
|
Hi, I have created a .Net Applet that connects to an FTP server via sockets. The problem is that the connection to the socket takes a long time (at around 100+ seconds). I tried creating an implementation of the FTP class in a Windows Form and I got connected faster (roughly 1-3 seconds).
Are there issues when connecting/opening sockets in .Net Applet?
sample code
public Boolean Login()
{
// Create socket
m_objClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
// Create IPEndpoint
IPEndPoint ep = new IPEndPoint(Dns.Resolve(m_sRemoteHost).AddressList[0], m_iRemotePort);
try
{
// Connect Socket takes a long time in applet
m_objClientSocket.Connect(ep);
}
catch(Exception ex)
{
MessageString = m_sReply;
throw new IOException("Cannot connect to the remote server. Error: " + ex.Message);
}
.......
|
|
|
|
|
You might get better answers if you post in the windowsforms.net forums. .NET 'applets' are so sparingly used, it seems to me that most people will have no idea why it works slower over the web like this.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: The Secular Left, the Religious Right, and Prejudice
Judah Himango
|
|
|
|
|
A GUI have many controls, such as radiobutton, checkbox etc.
After configurate GUI, click "OK" button, how to save current configuration?
ths!!!
|
|
|
|