|
Thanks for the info. I'm starting a SetColor class definition now using that example. So now I'm off to start parsing text.
|
|
|
|
|
|
i need to create a program that can convert gregorian date, month and year to lunar date, month and year. help plz.. anw how to declare date in c# and use it? for example in VB.NET is dim d as date; date = #01.02.2005#....
chris
|
|
|
|
|
You declare a date in C# the same as you do with any managed language (barring any shortcuts like with VB.NET): DateTime dt = DateTime.Now (or use any other methods of the DateTime structure.
You can use the Calendar class derivatives to convert to and from different calendars.
I recommend ready about both the DateTime structure and the Calendar class in the .NET Framework SDK, which can be installed standalone and is installed by default with Visual Studio .NET.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Anyone know how to convert this following VB.NET to C# ?
Private WithEvents _PStatus AS StatusBar
Private Sub DrawItem(ByVal sender As Object, ByVal sbdevent As System.Windows.Forms.StatusBarDrawItemEventArgs) Handles _PStatus.DrawItem
Thank
|
|
|
|
|
I'd try this:
private StatusBar _PStatus;
private void DrawItem(object sender, StatusBarDrawItemEventArgs sbdevent)
But you have to tell the StatusBar that DrawItem is the event handler for the DrawItem event by writing:
_PStatus.DrawItem += new StatusBarDrawItemEventHandler(this.DrawItem); after you've created the StatusBar.
Regards,
mav
|
|
|
|
|
Thank your..
But it doesn't work. Let me description more detail.
MyStatusBarPanel Class :
private StatusBar _PStatus;
public void DrawItem(object sender,
System.Windows.Forms.StatusBarDrawItemEventArgs sbdevent)
{ }
public StatusBarProgressPanelClass(StatusBar sb)
{
_PStatus = sb;
_PStatus.DrawItem += new StatusBarDrawItemEventHandler(this.DrawItem);
}
MyMainForm :
pnl = new MyStatusBarPanel(statusBar1);
|
|
|
|
|
Without explicitely trying for myself the only thing I see right now that _could_ cause problems would be a naming conflict between the event DrawItem and the event handler function DrawItem.
Change public void DrawItem() to private void OnDrawItem() and += new StatusBarDrawItemEventHandler(this.DrawItem); to += new StatusBarDrawItemEventHandler(this.OnDrawItem);
then it could work.
If it doesn't then it would help to know what errors you get.
mav
|
|
|
|
|
Hi Mav,
Thank your help. Actually, I forget to set a property of my parent contol, so the DrawItem never work. I find out my problem.
P.S: your first response is work fine.
Thank again
|
|
|
|
|
Hello all,
Having problems trying to figure out how to call some special mathematical c functions that are in a .h file from C#.
One method that I can think of is to create an interface to the functions via a dll. Are yee aware of any other methods of doing this without using dlls?
Also, I'll be passing multiple integer and float arrays to the functions, some of which will be used to store the results of the functions. Are there any pitfalls with conversions from the managed to unmanaged memory locations that I should be aware of when doing this?
Thanks in advance,
Donal
|
|
|
|
|
You should look into P/Invoke. I would suggest you start here: Platform Invoke Tutorial[^]. There is a lot of documentation available on CP and MSDN covering this. Understand your data types is vital. Even though the following link is titled "COM Data Types", many of these still apply if you are simply calling C++ functions in C#. COM Data Types[^] is a good read. If you are trying to call anything COM based in C#, I would suggest you read about Runtime Callable Wrapper's[^]. Hope this help.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi Nick,
Thanks for the info.
Donal
|
|
|
|
|
How can I disable focus on few buttons?
|
|
|
|
|
Select your button in the form designer.
Switch "Properties" to the "Events"-Mode.
Then scroll to the "Focus"-Section and give some method name for "Enter".
I used "button1_FocusEnter".
This will create an empty method in which you put one line:
someOtherControl.Focus;
You can also prevent users from "tabbing" through your control by setting "TabStop" to false.
With the "coded" solution, the button will never keep focus, the someOtherControl will receive Focus instead.
That will not prevent anyone from pressing that button, though.
If you want users NOT to press a button, disable it.
If you set TabStop to false, the control still gets focused if someone presses it.
If you combine both ways, the button will never KEEP focus, but users can still press it and trigger it and stuff.
Cheers
Sebs
|
|
|
|
|
Great, thank you for beeing patient and explaning me in this way.. thanks 
|
|
|
|
|
Another, perhaps easier way is to create a button that's not selectable per-se.
Create a new class InertButton that inherits Button .
In the c'tor you just add the following line:
SetStyle(ControlStyles.Selectable, false); That's it.
Use this InertButton exactly the same way you would use a regular button.
Regards,
mav
|
|
|
|
|
Thanx mav 
|
|
|
|
|
I would like to set another collor of my buttons if they were disabled.. How can I do it?
Thank You
|
|
|
|
|
Somthing like this:
if(mybutton.Disable)
mybutton.BackColor = Color.Blue;
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
thanks 
|
|
|
|
|
Im trying to support labeledit in my ListView control but
i am stuck on getting the ListViewItem object edited.
In the EventArg to EndLabelEdit there is an Item member
telling which index was edited but how do i get the ListViewItem
from the index?
listView1.Items returns the ListViewItemCollection and according
to the help there should be an Item property there but it
is not there...
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
|
Surely there must be some way of getting the ListViewItem by index without using SendMessage() ?
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
If I understand your problem correctly then a simple
ListViewItem theItem = listView1.Items[e.Item]; would be the answer (with e being the LabelEditEventArgs ).
Can it be so simple?
mav
|
|
|
|
|
Hmmm..i was so sure that was the first thing i did try, it is that simple....i better start sleeping at nights.
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|