|
I get your problem now. There's no way that the Items.Clear() doesn't work.
The problem might be from drawing(paint event(s)).
Ex: you drop your control on the form. The Ctor calls the RepopulateChoices.
Then the paint event is raised and ads the items once again.
Drop on a panel on a form. Form invalidate=> your control invalidate.
Panel invalidate again => your control invalidates.
That's the only reason that I could think of.
But it might not be this at all.
Do you override the OnPaint?
|
|
|
|
|
The problem are the static items in the Items property on design-time.
Just go to your form design->select a pcaTimePicker->Properties->Items delete everything in it.
After that you should not have any problems.
The problem are the following lines in the designer-file:
this.pcaTimePicker3.FormattingEnabled = true;
this.pcaTimePicker3.Items.AddRange(new object[] {
"12:00 ",
"12:30 ",
"1:00 ",
"1:30 ",
"2:00 ",
"2:30 ",
...});
this.pcaTimePicker3.Location = new System.Drawing.Point(101, 243);
this.pcaTimePicker3.Name = "pcaTimePicker3";
this.pcaTimePicker3.Size = new System.Drawing.Size(121, 21);
this.pcaTimePicker3.TabIndex = 5;
Those lines get called after your pcaTimePicker first invokes Repopulate(...).
Here some example:
public Form1()
{
InitializeComponent();
MessageBox.Show(pcaTimePicker3.Items.Count.ToString());
pcaTimePicker3.Items.Clear();
pcaTimePicker3.Increment = 30;
MessageBox.Show(pcaTimePicker3.Items.Count.ToString());
}
Hope I could help you.
Greetings
Covean
|
|
|
|
|
BRILLIANT, Covean!!! I never would have thought of looking at the designer file. That started me thinking that there has to be a way to prevent design-time population. At first I just tried adding a check against the ComboBox.DesignMode property. However, RepopulateChoices() is also called from the constructor, and DesignMode doesn't register that early. On the other hand, if I removed the call from the constructor, then nothing was populated at run-time. My final solution was:
1. Remove the call to RepopulateChoices() from the constructor.
2. Override the InitLayout method like this:
protected override void InitLayout()
{
base.InitLayout();
if (DesignMode) return;
RepopulateChoices();
}
That prevents any items from being populated at design time and still populates the ComboBox at run-time with exactly ONE set of data.
Thanks again.
|
|
|
|
|
|
And 5 for the answer seeing as OP forgot!
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thank you.
Greetings
Covean
|
|
|
|
|
if any one know then please help me ....
|
|
|
|
|
You can use the media player component to play a video. Just add it to your form and set its source as appropriate.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks for your help. i done it. now i want to take a snapshot image from a video file. then tell me how can i get a snapshot image from a video file programatically?
|
|
|
|
|
I have set the form border to FixedSingle and removed the max, and min buttons but the user is still able to re size the form by double clicking on the title bar..
how can I prevent that?
|
|
|
|
|
Have you set The form's boarder style property to one of the "Fixed" enumerations (e.g. "FixedDialog")?
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
it is set to fixed single as mentioned..
is there any way to prevent resizing using winapi & c#?
|
|
|
|
|
Set the Min and Max sizes?
|
|
|
|
|
You can disable title bar double click by using this technique:
public partial class MyForm : Form
{
const Int32 HTCAPTION = 0x2;
const Int32 WM_NCLBUTTONDBLCLK = 0xA3;
protected override void WndProc(ref Message msg)
{
switch (msg.Msg)
{
case WM_NCLBUTTONDBLCLK:
if (msg.WParam.ToInt32() == HTCAPTION)
return;
break;
};
base.WndProc(ref msg);
}
}
|
|
|
|
|
That's good work. I've just created a form, fixed single without min and max buttons and it definitely doesn't maximise on double clicking the titlebar.
Regards,
Rob Philpott.
|
|
|
|
|
I want to have my form title on the left side of the title bar as usual... but I also want to have a form ID like FRM123 on the right side on the form just beside the minimize button or right most if no buttons..
how can I do that?
|
|
|
|
|
jrahma wrote: form ID like FRM123
That will be a very unprofessional thing to do
Harvey Saayman - South Africa
Software Developer
.Net, C#, SQL
you.suck = (you.Occupation == jobTitles.Programmer && you.Passion != Programming)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
can I ask why?
it will be easier to identify the form specially when supporting basic users on the phone..
|
|
|
|
|
String s ="";
int? nullint = s ( How to convert "String s" to "nullable int")
|
|
|
|
|
|
First, I'd avoid nulls unless absolutly neccesary, the can cause all sorts of problems if they are not coded against.
The exact code you need depends upon your desired "failure mode" (see comment in block) but here is an answer:
static int? Convert (string value)
{
if (string.IsNullOrEmpty(value))
return null;
int returnedInt;
if (int.TryParse(value, out returnedInt))
return returnedInt;
return null;
}
also IMO nullint is a shoud be renamed as it has both "null" and "int" in it, as well as not being very descriptive.
[Edit]
Nuri Ismails post (below) achieves the same as the above, but is more compact, so I'd use that in preference.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
modified on Wednesday, January 20, 2010 9:00 AM
|
|
|
|
|
How about something like this:
public int? ToNullableInt32(string s)
{
int i;
return (Int32.TryParse(s, out i)) ? i : null;
}
String s ="";
int? nullint = ToNullableInt32(s);
|
|
|
|
|
Hi All,
I am trying to develop a .net framework v2 webservice suitable to receive a .pdf as a MIME attachment.
I have search the web but I can't find anything related.
Could you please assist
Tony
|
|
|
|
|
Hi,
In my program i'm trying to access a server drives details from my machine with different username and password, for this i'm using the connections options class in C#,
here is the code i'm using
try
{
ConnectionOptions opt = new ConnectionOptions("MS_409", "USERNAME", "PASSWORD", "ntdlmdomain:DOMAIN", ImpersonationLevel.Impersonate, AuthenticationLevel.Default,false, null, TimeSpan.MaxValue);
ObjectQuery query = new ObjectQuery("SELECT FreeSpace, Name FROM Win32_LogicalDisk WHERE DriveType = 3");
ManagementScope scope = new ManagementScope("\\\\" + "16.106.64.108" + "\\root\\cimv2", opt);
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection coll = searcher.Get();
foreach (ManagementObject ms in coll)
{
Console.WriteLine(ms["Name"]);
Console.WriteLine(Convert.ToDecimal(ms["FreeSpace"]) / 1024 / 1024 / 1024);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
whenever i reach line "ManagementObjectCollection coll = searcher.Get();" i'm getting the "Invalid Parameter" error, i could not find a slution for this, please help.
Thanks,
D.Vinoth
|
|
|
|
|
You wrote:
... i'm trying to access a server drives details from my machine with different username and password for this ...
Don't you have to change the value "ntdlmdomain:DOMAIN" also to a valid domain on the remote machine?
Sorry thats the only idea I have. Everything else seems to be right and your query works also on my system.
Greetings
Covean
|
|
|
|