|
Hallo, I have a strange problem:
When I use DrawString in a drawitem event the text ignores font and brush.
I have a listbox, the unselected items catch the font and brush, but the selected item doesn't. It is printed as unselected.
Do you have any answer??
Bye
|
|
|
|
|
The DrawItemEventArgs contains the properties you need to draw the items, but you must use its State property to determine the state of items, like whether or not it is selected. Keep in mind that since the DrawItemEventArgs.State property uses a flag enumeration, you must use bitwise operators to determine state. For instance, to find out if the item is selected, use something like the following:
bool selected = (e.State & DrawItemState.Selected) != 0;
if (selected)
{
}
else
{
} See Resizable ListBox[^] for a pretty good example (there's many others, too - I just still had that URL in my clipboard used for another reply just a minute ago).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am trying to do a word wrapping in the items of the ListBox.
But I donot see any such property provided by ListBox.
Any idea how can I do this.
Any help would be appreciated.
Thanks,
Binal
|
|
|
|
|
You have to owner-draw the items, and there are a couple articles here on CodeProject that explain how. See An editable multi-line listbox for .NET[^] or Resizable ListBox[^] for a couple decent examples.
Basically, you just owner-draw the ListBox using a multi-line StringFormat and call Graphics.DrawString with that StringFormat . Slightly more is involved, but see the articles for details.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i try to much to deal with the video in the C#
i try to use DShowNet but i don't understand its functions so i need so urgent to know
1- the class or library or dll ..... used to deal with a video in the program
2- i need to cut the video into frames and give each frame its index
3- convert the frames into images
|
|
|
|
|
If you're the same person that posted something similar a couple days ago, I gave you a link to one article here on CodeProject. If you don't understand it's functions, read any documentation available including source code comments or ask the authoring using the message board at the bottom.
No one's just going to give you code, and even in such a case you'll still need to understand it in order to implement it. If you're simply looking for a program that can do this, there are hundreds out there, even some installed with your OS (Microsoft Movie Maker, for example, can slice WMVs).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Guys,
Im trying to display the ID (Next New One) on the form each time the New Record is entered. I m using this code, but it displaying the wrong ID.
this.txtFileId.Text = ((int)myDs4.Tables["tblFiles"].Rows[myDs4.Tables["tblFiles"].Rows.Count - 1]["fid"] + 1).ToString();
where 'fid' is the column in Table with autonumber type.
Thanx in advance.
Regards
msls
|
|
|
|
|
A new record which hasn't been committed with data yet won't have a new ID. The data must be committed to a row before the ID exists in the DataRow . This is why record navigators (including the DataGrid itself) display a "*" until the record is committed.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanx for ur reply. If u look in my code, I m trying to get Id of last record and trying to add 1 into that but it still not giving me the correct id of the last record. coul du pls confirm the code to access last record in OK or something wrong into that.
Thanx
msls
|
|
|
|
|
This would only work if your DataTable was sorted by ID.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanx alot, its working now. I was thinking that coz the ID field id automuner and PK as well in the table, it would be sorted by default.
Thanx
msls
|
|
|
|
|
Hi
Someone knows, if it's possible regenerate a print preview? I have a form with a Print Preview Control, and if I change the paper orientation via a Page Setup Dialog this don't update the print preview.
Thanks
----
hxxbin
|
|
|
|
|
Is the PrintPage event handler called again? Put a breakpoint in your code and see. Otherwise, handle the StartPageChanged event on the PrintPreviewControl .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I got a stupid idea:
<br />
this.printPreviewControl1.Document = null;<br />
this.pageSetupDialog1.ShowDialog();<br />
this.printPreviewControl1.Document = this.reportDocument1;<br />
and works .
|
|
|
|
|
Hi, I want to build MDI Application. I got success in 1st level of MDIChild forms now the problem is that if the 1st level of MDI child form open new forms those forms cannot be included as MDI child becoz those are child forms of the 1st level MDI child form. So could u plz tell me how to proceed in this, to build an application in which all forms as child forms of the main MDI form. or is there any other wayout. Thanks for ur support.
|
|
|
|
|
Whenever you create a new MDI child form, just set the MdiParent property to the main form. So, if a child MDI form created a new child, it's MdiParent is what you'd set as the new form's MdiParent .
See the Form.MdiParent property documentation in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you, i got it running!
frmDlabMenu cpForm = new frmDlabMenu();
cpForm.MdiParent=this.MdiParent;
cpForm.Show();
this.Hide();
|
|
|
|
|
Hi!
In my app I'd like to execute some code when an AppDomain is unloaded. I expected AppDomain.DomainUnload to be suitable for this, however the event never gets raised automatically - only if I call AppDomain.Unload with that AppDomain.
Example:
class Class1
{
static void Main(string[] args)
{
AppDomain.CurrentDomain.DomainUnload += new EventHandler(CurrentDomain_DomainUnload);
AppDomain domain = AppDomain.CreateDomain("Test");
domain.DomainUnload += new EventHandler(CurrentDomain_DomainUnload);
}
public static void CurrentDomain_DomainUnload(object sender, EventArgs e)
{
Console.WriteLine("Unloading appdomain");
AppDomain domain = sender as AppDomain;
if(domain != null)
Console.WriteLine("... unloading domain is: " + domain.FriendlyName);
}
}
I find this quite irritating. How can I implement some kind of per-AppDomain shutdown function?
Thanks in advance. Regards,
Andre Loker
|
|
|
|
|
What about the ProcessExited event?
|
|
|
|
|
ProcessExited only works for the main AppDomain (and even then, I find strange bevahvior to occur).
Regards,
Andre
|
|
|
|
|
Hi!
On www.pinvoke.net I've read this:
[DllImport("shell32.dll")]<br />
static extern IntPtr ShellExecute(IntPtr hwnd, string lpVerb, string lpFile, string lpParameters, string lpDirectory, int nShowCmd);
And now I wonder:
1) does this work? "ShellExecute" doesn't exist in shell32.dll, only ShellExecuteA and ShellExecuteW.
2) If it works: which one (A/W) will .net choose?
So we come directly to the second question: the "string" type. Is this type a Unicode or ANSI string? Is the type dependent on the system the .net interpreter runs on (i.e. on Win98 it would be ANSI, on WinXP Unicode) ?
What I wonder too: what if we want to use a function like GetWindowsDirectory? This function wants a pointer to a string buffer which will receive the string. Well, now in C# we just declare "string s", without specifying any size of the buffer... Any way to allocate a string which can hold a specific amount of characters we can define manually?
If you know an excellent page on C# strings, please tell me
Thanks in advance and best regards,
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
First, also add the CharSet=CharSet.Auto to your DllImportAttributE so that the strings are marshalled correctly. The CLR will pick the ANSI or Unicode (A and W endings, respectively), based on the current platform (Windows vs. Windows NT). If you ever wanted to call one of these specifically, you can set ExactSpelling to true.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
server side, I got a class containing a method like this :
DB_Access_Class() : MashalByRefObject
public string Execute_Query(string query)
The DB_Access_Class instances got infinite lease time.
The goal is to share the same instance between all clients.
client side, I got a proxy (singleton mode) on a remote DB_Access_Class
Now, i want several Clients to be able to run Execute_Query at the same time.
I don't care (and would even prefer actually) if the client is locked while waiting for server answer.
But i don't know the best way to implement this and can't find any example on the net.
Is there any way to implement this without using asynchronous calls ?
Thanks,
Etienne.
|
|
|
|
|
You want the same client to execute the remote method multiple times at once? Or do you want multiple clients (i.e., multiple processes, perhaps even on different machines) to call it? The latter is already taken care of for you, which is why you should internally lock any resources if appropriate in your remote method.
If you want the same client to call it multiple times asynchronously, what's wrong with just calling it asynchronously? Otherwise, you can always create several threads, each of which would call it, but asynchronous method calls give you a little more control about when to receive the output of the method as well as polling options, which you'd have to add functionality for if you just used threads.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
You want the same client to execute the remote method multiple times at once? Or do you want multiple clients (i.e., multiple processes, perhaps even on different machines) to call it? The latter is already taken care of for you, which is why you should internally lock any resources if appropriate in your remote method.
Indeed, it's about multiple clients, each of one doing 1 single call at a time. But from the tests i ran, here's what happens :
Client 1 calls remote_method
Client 2 calls remote method
remote_method takes 30 seconds to complete and returns result to Client 1
remote_method takes 30 seconds to complete and returns result to Client 2
So Client2 will wait 60 seconds before getting his result, which is not acceptable in my case where i'll have up to 15 clients calling the service. I need the server to treat requests simulteanously, which is why i need him to create a new thread on each call.
I just don't know the best way to implement this, and if i absolutely need asynchronous dialog using deleguates (which would require to have a MBR object client-side too, from what i understood)
Thanks for quick reply though, i really appreciate
Etienne.
|
|
|
|