|
Martin# wrote: I know that it could be multible text in the Items!
Exactly! What can I do in case I have multiple items with the same text in the ComboBox?
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Hello,
brahmma wrote: What can I do in case I have multiple items with the same text in the ComboBox?
The question is what do you want it to do.
All the best,
Martin
|
|
|
|
|
Hmm... I want to execute a piece of code whenever the user changes his selection in a combobox. But the TextChanged handler may not work if I have duplicate items in the combobox. And the SelectedIndexChanged will be called even if the user selects the same item again, which sucks. So, do I need to check manually if the user has selected a different item every time and then execute my code? If yes, then why do we have event handlers?
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Hello,
brahmma wrote: And the SelectedIndexChanged will be called even if the user selects the same item again, which sucks
So true!
brahmma wrote: So, do I need to check manually if the user has selected a different item every time and then execute my code?
I think in your special case, yes!
brahmma wrote: If yes, then why do we have event handlers?
I guess this statetment comes out of frustration.
An other possibility is, you do what MS was not willed todo:
inherit your own combobox, like this:
public class SpecialComboBox : System.Windows.Forms.ComboBox
{
private bool init = true;
private int oldIndex = 0;
public SpecialComboBox()
{
}
protected override void OnSelectedIndexChanged(EventArgs e)
{
if((oldIndex!=this.SelectedIndex)|| init)
{
init=false;
oldIndex = SelectedIndex;
base.OnSelectedIndexChanged (e);
}
}
}
This should do it!
All the best,
Martin
|
|
|
|
|
Very good idea to create your own control that enhances performance of the vendor. I will vote 5 for your message Martin.
My greetings
Mohamed Gouda
Egypt
|
|
|
|
|
Thank you!
All the best,
Martin
|
|
|
|
|
Imagine an ERP package under development with some 300 forms (to which I have access). There are 500+ combo boxes. Now, I have to inherit my own combobox and then... Thanks, Microsoft.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
brahmma wrote: I have to inherit my own combobox and then
It's not good style but it works:
Change it directly in the .cs file (InitializeComponent code)
Replace in the editor "System.Windows.Forms.ComboBox" to "YoureNamespace.SpecialComboBox"!
-- modified at 7:20 Tuesday 10th July, 2007
All the best,
Martin
|
|
|
|
|
Hello C# guru's,
I've done my research but I just couldn't find one that does the following.
I have an MDI application. In the child form there is a panel whose height is dependent on the
current client area height of the child form. The child form is set to a default size when created but its size can be adjusted afterwards and can also be maximized. If I set the currently active child window to maximized and then open another child window, the panel height of the latter is set based on the default height of the child form even though it opens maximized. How do I make the child form calculate its actual client area whether it's maximized or not?
TIA!
I am a SysAdmin, I battle my own daemons.
|
|
|
|
|
Hey I’m developing a windows service (with C# .net 2005) to access the outlook 2003 calendar.
I’m running the service account as a Network Service
-------------------------------------------------------------------------------------------------
this.serviceProcessInstaller1.Account =
System.ServiceProcess.ServiceAccount.NetworkService;
----------------------------------------------------------------
Service is instlling properly. But when I strat the service error pope out saying unotheraized access at the point I create outlook object.
----------------------------------------------------------------
private Outlook.Application objOutlook = new Outlook.Application();
----------------------------------------------------------------
Error: An unhandled exceptoin (“System.UnathorizedAccessException”) occurred servicename.exe[2804]
|
|
|
|
|
Well your trying to access something and it's saying your unauthorised. Now feel free to call me crazy but it sounds like your unauthorised to access outlook from that account :P
It might be that thats not the problem but the easiest way to test is to give the service your user account and test it again. If the problem goes away then the network service doesn't have the permissions needed.
|
|
|
|
|
|
I am familier with MS Access rather than SQL
And to do that there, I choose my format in the database designe phase (Set the date field format to whatever you want). and do not need coding for this.
I think SQL Server provides same thing
Mohamed Gouda
Egypt
|
|
|
|
|
Hi
Use SET DATEFORMAT
See the example below:
<br />
Example 1 : executes without any error <br />
<br />
use northwind<br />
go<br />
<br />
set dateformat dmy<br />
go<br />
<br />
select top 10 * from Orders where requireddate >= '15-08-1996'<br />
<br />
Example 2 : gives error <br />
<br />
use northwind<br />
go<br />
<br />
set dateformat mdy<br />
go<br />
<br />
select top 10 * from Orders where requireddate >= '15-08-1996'
Harini
|
|
|
|
|
And this works from code in .NET?
Thanks anyway!
--------------------------------
visit: http://pmartike.deviantart.com/
|
|
|
|
|
just type cast datetimr to string and give parameter as your desire format
like:-
.ToString("dd/mm/yyyy");
Mohammad Mustafa
|
|
|
|
|
this returns me a string like this: "10/46/2007" if i used for today's date..
--------------------------------
visit: http://pmartike.deviantart.com/
|
|
|
|
|
mm represents minutes. Use MM for the month.
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
thanks
--------------------------------
visit: http://pmartike.deviantart.com/
|
|
|
|
|
Please consider using an ISO 8601 compliant format -- .ToString ( "yyyy-MM-dd" )
|
|
|
|
|
Thanks!
Problem solved
--------------------------------
visit: http://pmartike.deviantart.com/
|
|
|
|
|
Hello every body,
I want to refresh or reload the form1 on the click event of button on form2.
Actually form1 contains the listview and form2 is edit form on the click event of update button i want to refresh the form1 in order to see the updated result.
But i am unable to do so.
Regards,
Rahul
rahul saini
|
|
|
|
|
Hello,
monuSaini wrote: But i am unable to do so.
Why? Do you think, you have no access to the form1,
or haven't you found the Refresh() method of the form?
All the best,
Martin
|
|
|
|
|
Hello Martin,
Thanks for rply.
But it is not working.
the updated row does't showe the updated result.
Only when i reloads or re populates it is appears.
Regards,
rahul saini
|
|
|
|
|
Hello,
monuSaini wrote: the updated row does't showe the updated result.
Have you tried to use the Refresh method?
I think we have to see some code snippeds.
All the best,
Martin
|
|
|
|