|
HEY! Thanks..but i've already written that code..it is to use a datatmepicker in a datagrid...but u dinn get what i asked...i wld appreciate if u cld help me...
i have a datagrid on a usercontrol which has two columns of DateTimePicker style. They are 'From Date' and 'To Date'.
when i enter data in the first row, i select the date in the two columns. So when i add data in the second row, the dateTimePicker in 'From Date ' Should show me the next day of the date that i entered in the 'To Date' of the previous column. This should happen for all the rows that i enter..
plz tell me how to do this..
|
|
|
|
|
Please override the Edit method of the DataGridDateTimePickerColumn control and Fire a custom event. Subscribe to the event in the usercontrol and do the processing.
protected override void Edit(System.Windows.Forms.CurrencyManager source, int row, System.Drawing.Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible)
{
CustomEventArgs e = null;
this.row = row;
//
//Fire Event and Take Decision
//
if (this.CustomEvent != null)
{
e = new CustomEventArgs(row, this.column, isEnabled, bounds);
this.CustomEvent(this, e);
this.isEnabled = e.IsEnable;
this.isReadOnly = e.IsReadOnly;
}
if (this.isEnabled)
{
if (((CurrencyManager) source).Position == row)
{
base.Edit(source, row, bounds, readOnly, instantText, cellIsVisible);
this.source = source;
}
}
else
{
if (this.isReadOnly)
{
if (((CurrencyManager) source).Position == row)
{
base.Edit(source, row, bounds, true, instantText, cellIsVisible);
}
}
}
}
This is in the usercontrol
private void OnGridEnableDisable(object sender, CustomEventArgs e)
{
try
{
if (
this.hitTestGridInfo != null &&
this.hitTestGridInfo.Type == DataGridEx.HitTestType.RowHeader
)
{
e.IsEnable = false;
}
else
{
switch (e.Column) // remember to initialize the picker column with this index
{
case 4: // i.e. To Date
// put your logic
case 5: // From Date
}
}
}
catch
{
}
}
I hope this helps.
Live Life King Size
Alomgir Miah
|
|
|
|
|
I've been triying to make a csc.exe link for typing at the console "csc.exe myfile.cs..." and not the entire csc.exe path, i posted a topic days ago but recomendations didn't work. I tried to add a system variable but didn't worked too. What do you suggest?. MS .NET SDK is not installed on my system.
Thanks
|
|
|
|
|
|
You add the path to the environment using:
set path=%path%;c:\the\path\to\the\program
---
b { font-weight: normal; }
|
|
|
|
|
I have several self-contained C# samples, and I want to show them run to students in class. So I wrote a program, in which I opened the source file, and then ....
Microsoft.CSharp.CSharpCodeProvider cp
= new Microsoft.CSharp.CSharpCodeProvider();
System.CodeDom.Compiler.ICodeCompiler ic = cp.CreateCompiler();
System.CodeDom.Compiler.CompilerParameters cpar
= new System.CodeDom.Compiler.CompilerParameters();
cpar.ReferencedAssemblies.Add("system.dll");
string src = this.textBox1.Text;
System.CodeDom.Compiler.CompilerResults cr = ic.CompileAssemblyFromSource(cpar,src);
foreach (System.CodeDom.Compiler.CompilerError ce in cr.Errors)
MessageBox.Show(ce.ErrorText);
if (cr.Errors.Count == 0 && cr.CompiledAssembly != null)
{
Type ObjType = cr.CompiledAssembly.GetType(classname);
try
{
if (ObjType != null)
{
string[] arguments={};
myobj = Activator.CreateInstance(ObjType);
ObjType.InvokeMember("Main", BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Static|BindingFlags.IgnoreCase, null, null, arguments);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return true;
}
My problem is when I run it, I always catch the exception MissingMethodException, i.e. the method "Main" cannot be found.
In textBox2, I input "P2_1.FirstProgram", that's the class which hosted the method "Main".
I guess the "ObjType.InvokeMember" caused the problem, but MSDN did not tell me how to do clearly.
Help!!!!!
|
|
|
|
|
I've written a C# Jukebox app ( like, a year ago ) and the client has been very slow to test it. They are reporting a couple of problems, first that they have trouble with the coin mech stopping working, and second on some that all input is ignored. Now, these jukeboxes use custom input devices, through the parallel and joystick ports. I have used model/view/controller, and the various controller classes typically contain a timer which fires 10 times a second and checks the state of a button, if it's on, it stores the fact and then won't accept input until it's been off again, and fires an event to the model. I've discovered that these machines are left on for weeks at a time.
The problem appears most with the joystick, which is used to catch credits. Windows shows that the joystick is working ( through the control panel applet ), but the software does not accept input until it is rebooted. So I'm wondering if there's any known issue where software that runs a timer over and over can break down because the timer fails ? It seems weird to me, but it's the only explanation I can come up with.
In the meantime, I'm looking into using DirectInput for the joystick, but I'd still like to understand why the current approach is not working reliably.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Just a wild guess, maybe you need to declare the member that you access from two threads (the button state) as volatile?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Actually, it's all running on the same thread. What does volatile do for me ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
What timer call are you using?
.............................
There's nothing like the sound of incoming rifle and mortar rounds to cure the blues. No matter how down you are, you take an active and immediate interest in life.
Fiat justitia, et ruat cælum
|
|
|
|
|
I'm just creating a timer - do they automatically run on another thread?
private Timer timer = new Timer();
in the constructor....
timer.Interval = 100; // poll 10 times a second
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
http://msdn.microsoft.com/msdnmag/issues/04/02/TimersinNET/default.aspx[^]
The key here is that some timers can get pre-empted or simply "stop" running depending on the class you use. The windows forms timers can be really quirky.
.............................
There's nothing like the sound of incoming rifle and mortar rounds to cure the blues. No matter how down you are, you take an active and immediate interest in life.
Fiat justitia, et ruat cælum
|
|
|
|
|
Cool - thanks for the info.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
The timer callbacks occur on another thread, unless you're using the Windows Forms timer, in which case, the callback/event will occur on the UI thread. So you do have two threads, my guess is that you are accessing a shared variable without locking (may not be needed) and without declaring it volatile.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
S. Senthil Kumar wrote:
unless you're using the Windows Forms timer
Which I thought I was.
S. Senthil Kumar wrote:
my guess is that you are accessing a shared variable
OK - I'll look into that, thanks for the help.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Was the UI responsive when the timers stopped working? Maybe the message pump got blocked and the timer messages didn't get processed at all?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
The UI stays responsive, and it's consistent in it's demands, it would have been using another timer to display static images, and allowing browsing of a song list that no-one could access because they coin mechanism didn't respond to having money put in it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi
im using MS access as my database... i've to receive data from another computer and store the data in my database... initially, both computers were using string for read and write... my computer would get the data and store them in a text file... but as the data will keep on increasing and it is a huge amount, as well as for better layout, my computer will now use database to store data instead of in a text file>notepad...
the codes used in the other computer is in string and i will NOT be changing the codes in that computer..
im not sure how a computer using string to read and write data will be able to pass data successfully to a computer using varchar for database.. i know i can use a wizard to convert data in text file to table form in database..
but what i want to do is to pass the data directly into a database from the other computer without having the user to need to use a wizard..
the user is supposed to click on a button in a form in my computer and the data will be retrieved from database for user to view/update...
my question is: how do i write/change my codes in MY computer in order for the data passed over to directly be stored in a database? (the data will not be kept in text file any more..)
thanks a lot!
|
|
|
|
|
nidhelp wrote:
im not sure how a computer using string to read and write data will be able to pass data successfully to a computer using varchar for database..
Make sure your varchar is as long as the longest possible string you'd pass in. That's it.
nidhelp wrote:
but what i want to do is to pass the data directly into a database from the other computer without having the user to need to use a wizard..
Do you know any SQL ? What you're after is a simple INSERT.
nidhelp wrote:
my question is: how do i write/change my codes in MY computer in order for the data passed over to directly be stored in a database? (the data will not be kept in text file any more..)
Connect to a database with a table that has a varchar value, and do an INSERT into it. Do you intend on making this data easy to search in any way ? Will you at least put a datastamp on it ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Well, my DLLs remain locked by my application even after I do an AppDomain.Unload(). I haven't investigated deeper but I was hoping there's someone who has ran across this before. I'm quite sure the assemblies cannot be loaded in any other appdomains, so... meh.
Since it's too late for coding here, I'll see tomorrow whether the AppDomain really unloads or if it goes funky...
|
|
|
|
|
Are you unloading an AppDomain that you created on your own? If so, are you sure you didn't access any type from any assembly in that AppDomain?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Yeah, I created it. Well, I create a few objects and use them via a proxy (AppDomain.CreateInstance()) but that shouldn't matter, right?
|
|
|
|
|
I haven't used AppDomain.CreateInstance, but MSDN has this to say
"when this method attempts to return the Assembly for the loaded assembly to the current application domain, the common language runtime will try to load the assembly into the current application domain "
That is pretty suspicious..
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Aha! Yeah, I'd better investigate that. Thanks for the tip
|
|
|
|
|