|
Hi,
I've been requested to create a custom combobox that gives the user the power to change the color of the outline (easy) and also the foreground/background for the drop down 'button' (the button to the right of a combobox with the down arrow). I can't figure out how to get a handle to that button. Can I do that? If not, can I create my own button of that size/shape and force it to use it instead? Would appreciate any help. I've found: ControlPaint.DrawComboButton, but that just takes a rectangle and a button 'state'. I need something more...
thanks very much,
Deanna
|
|
|
|
|
The HWND (window handle) of every Control is exposed from the Handle property. That returns an IntPtr that represents the HWND , and any native API that you P/Invoke should define any handle property (HWND , HDC , HRGN , etc.) as an IntPtr .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I realize that, but what I need to know is how to get the hwnd of JUST the button, not the whole combobox control.
|
|
|
|
|
ddelapasse wrote:
I realize that, but what I need to know is how to get the hwnd of JUST the button, not the whole combobox control.
The ComboBox class is simply a wrapper around the Win32 class, check out the ClassName property of a CreateParams object in the get_CreateParams method of the ComboBox class, it's value is "COMBOBOX". You will need to override the WndProc of a derived class inheriting from ComboBox to perform the task you are trying to complete.
- Nick Parker My Blog | My Articles
|
|
|
|
|
It isn't a control. A Combobox is - natively (like Nick pointed out) - an Edit control with UI elements drawn around it (basically). The button is drawn, just like you've found with the ControlPaint class members.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello All,
Have a "minor" issue that i hope someone here can help me with.
I have the following code [Example below] that runs throu all directories to find specific files (eg. doc files).
When the code is run from a user who have admin right, then there are no issues. but if its run as a user with no rights whatsoever i get into trouble.
Running in the directory C:\documents and settings with the folders Administrator, Admin, Lousy User, Teds & BillG.
When the code is run in standard user mode, it will stop executing the folders in that thread when there is no access rights on a folder - in this case it will begin with Administrator folder first, and stop search in that directory. meaning it will newer get to search the users own folder "Lousy User".
Is there any was to get over this issue?
hope u all understood my meaning by this.
<code>
try
{
foreach (string d in Directory.GetDirectories(sDir))
{
foreach (string f in Directory.GetFiles(d, filetype))
{
FileInfo fs = new FileInfo(f);
view.Items.Add(itm);
}
}
}
catch (System.Exception excpt)
{
// Console.WriteLine(excpt.Message);
}</code>
|
|
|
|
|
Off the top of my head, I'm guessing that an exception is thrown if you don't have access to the directory you are trying to get the files for. If that is the case then your try catch block should be around the inner loop rather than the outer loop - that will allow you to continue searching in other directories, at the moment as soon as a directory is encountered that you don't have permission to view an exception is thrown that will stop the rest of your process.
Does this help?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Hi all,
I am currently using the Outlook Model to get a list of all tasks from Outlook 2003. The list of tasks is encapsulated within a MAPIFolder object known as theTasks and then to grab each individual task we use foreach(TaskItem taks in theTasks.Items). I would like to encapsulate this functionality within an interface so that the user can plug-in other Personal Information Managers if SDK's exist, and would like these tasks to be displayed within the main interface and not have a dependance on the Outlook model. Is there any way of returning an object with a list of the tasks to the main interface, as I assume you cannot return multiple items from a particular method.
Any help on this matter would be greatly appreciated!
Paul Kiddie
Developer
interactivelogbook.tk
|
|
|
|
|
Well, the interface you're talking about wouldn't be tied directly with the Outlook object model (OOM), no other PIMs. As for a collection or array of objects, that's pretty simple: object[] . Since the OOM and any other PIMs' OMs would define types that you can't change (like implement other interfaces, and casting down may not always work) so you'd have to return a generic object. That doesn't help you much, though. You'd have to use reflection or the component model to discover properties and methods, and that would be very grueling. Another idea is to encapsulate the objects themselves into yet another interface or abstract class. This would require you to - for each item - wrap it (in your provider, since what you're referring to is a provider pattern) and store it in a collection or list (which is also a collection), then return that collection. That's not an uncommon approach, however. The component model - in many places - actually uses reflection, wraps properties (for example) in PropertyDescriptor s, puts those in a PropertyDescriptorCollection , and returns that.
To aide with the component model (for good design-time behavior), you might also look into implementing the ICustomTypeDescriptor interface if you want to customize the behavior or such a base class for use in the component model (to return "virtual" properties (shadowed), etc.).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I want to check whether the content in a datagrid cell has been changed or not... how can u achieve this?
samitha
|
|
|
|
|
The cell itself doesn't record anything - the underlying data set does. If you're binding to a DataSet , DataTable , or DataView , get the DataRow for the row for that cell and query the DataRow.RowState property.
There's several ways to do this. The easiest that takes sorting into account is like so:
CurrencyManager cm = (CurrencyManager)
dataGrid1.BindingContext[dataGrid1.DataSource,
dataGrid1.DataMember];
if (cm != null)
{
DataView view = (DataView)cm.List;
DataRowView rowView = view.Item[dataGrid1.CurrentRowIndex];
bool changed = rowView.Row.RowState == DataRowState.Modified;
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thnks 4 the reply...My actual requiremnt is this..
Suppiose u have a datagrid with only one row has been entred. When you click on the close button on the form(without giving the focus on any other control) it should check whether the row has a value. This ckeck happens correctly when u click else where on the form or on the next row and then try to close..
can anybody help me...?
samitha
|
|
|
|
|
Please state your actual requirement next time. It will save time.
You should still get the currency manager like I showed you in the first reply in your Form.Closing event handler. Then you can call CurrencyManager.EndCurrentEdit . See the method documentation for CurrencyManager.EndCurrentEdit for an example.
You could also use DataGrid.EndEdit , which also includes an example of usage in the method documentation in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi All,
I am trying to write an application like, that will do some jobs with the given time interval. Program reads from a text file, which like below...
-------------------------
job1 : 15 minute
job2 : 5 minute
job2 : 25 minute
program place a System.Timers.Timer() for each job, and add ElapsedEventHandler(OnTimedEvent); to do job. The problem is I could not tell the OnTimedEvent code what to do
private static void OnTimedEvent(object source, ElapsedEventArgs e)<br />
{ <br />
<br />
System.Windows.Forms.MessageBox.Show(null,"selam","naber"); <br />
}
how to set a parameter to pass this event an make it special for the job.
karanba
|
|
|
|
|
Derive a new timer from System.Timers.Timer and add a string (or any other data).
public class NewTimer : System.Timers.Timer
{
public string Name;
public NewTimer()
{
}
}
then use this class rather than System.Timers.Timer:
T1=new NewTimer ();
T1.Name = "Timer1";
T1.Interval = 4000;
T1.Elapsed +=new System.Timers.ElapsedEventHandler (this.vHandleTimer);
Then look at the NewTimer in your event hander:
private void vHandleTimer (object sender, System.Timers.ElapsedEventArgs e)
{
NewTimer T=sender as NewTimer ;
MessageBox.Show(T.Name );
}
Hope this helps!
Bill
|
|
|
|
|
Is it possible to add only the needed .NET dll's to an application as a resource to "pre-extract", so that a machine you are deploying your application to, does not need huge .NET framework installed for it to work? OR is there a way to capture the native code that the JIT compiles out of the MSIL and create a PE with it, or will something like that not include garbage collection, etc ?
|
|
|
|
|
|
Ahh, thank you very much sir! This is exactly what I was looking for and could never find.
|
|
|
|
|
Hi,
I am building a website which opens a site map in a child window (window.open - popup window) which displays in links to navigate for users.
How do i do this -
When the users clicks on the child window link, the parent window must load that particular page.
any suggestions? easy one i think...
|
|
|
|
|
Your question would be better handled in the ASP.NET Forum. Even though your app is being written in C#, it really has nothing to do with the language itself. Your question has everything to do with the ASP.NET technology though...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I thought u knew the answer! Rather than useless msgs you can post in the answer if you know!
$iva
|
|
|
|
|
He wasn't posting a "useless msg", he was politely pointing you to the correct place to post your question. I don't know the answer so i can't post what you want, but it looks like you haven't even taken the previous posters advice and posted your question on the ASP forums.
When someone is trying to advise you on how to get the quickest solution to what you want, you'd be better off taking there advice, rather than posting stupid replies like the one above.
Kev Pearman MCP
|
|
|
|
|
Another ungrateful S.O.B. has made it on to my BlackList!
Thankfully, this is a rare event and will not stop me from helping other people, like pointing them in the right direction, in the future.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
If I insert an image in the RichTextBox at runtime, can I drag/move it inside the RichTextBox with the help of mouse, just like we can move any control on the form during design time.
Please guide
|
|
|
|
|
I have a datagrid with this structure:
Column1 Column2 Column3
Name URL FilePathtoSaveTo
There are 1000 rows in the grid and I want to use the url (Column2) in an httpwebrequest and httpwebresponse to get web pages and then use the FilePathtoSaveTo (Column3) to write the web page to disk.
Anyone know of a foreach loop (or some other way) that will allow me to do this (return the cell values from columns 2 and 3 in order to be used as variables for my web request and write?)
Thanks,
Paul
(Also, the urls return text files that when saved with the .html extension, open as html files.)
|
|
|
|