|
Hi all,
Create a ListView and an ImageList to go with it. Set the following:
Set the ImageList.ImageSize to 250 x 250 in the editor and then add some images - it'll automatically scale them up if you use small images but, for this test, that won't matter at all.
Create a textBox somewhere for the feedback string you're about to get.
Define the ListView as:
ListView1.View=LargeIcon;
ListView1.LargeImageList = ImageList1;
Now create some items for the collection - three is plenty for now - only top level items and don't add any text; you want to show a row of thumbnails to the user, no text or sub-children.
Now, put the following code behind the MouseMove event for the ListView:
Point cp = ListView1.PointToClient (new Point(e.X, e.Y));
ListViewItem TheNode = ListView1.GetItemAt(cp.X, cp.Y);
if (TheNode == null)
{
textBox1.Text = "nothing";
return;
}
textBox1.Text = "item " + TheNode.Index.ToString() + " selected";
My ListView is 1000 wide and not that high (300) so I should get all three items in a horizontal row - and I do - but when I move the mouse around, I'm getting some very bizare feedback from GetItemAt(). In some cases, I get a null until I'm about 50 pixels below a ListItem and when I'm within the bounds of the ListItem image, I'll get a null!
Am I exceptional or is this normal behaviour? If it's normal, anyone know what on earth I can do to mitigate it? My users will be able to define a range of thumbnail sizes and have control over the size of the ListView at runtime.
SysInfo: .NET 4 / VS 2010 / XP SP3 / ex-Pascal hack on keyboard. SysInfo[3] = usual cause of errors
|
|
|
|
|
DaveGriffith wrote: Point cp = ListView1.PointToClient (new Point(e.X, e.Y));
I don't understand why you would do this, the coordinates are already relative to the receiver of the mouse events, hence ListView1.
|
|
|
|
|
Hi Luc,
Mainly because I'm trying to debug the problem I'm getting with sorting and DragDrop. When I try to use list reordering from an example Drag and Drop ListView row reordering
Using the e.X, e.Y values work as you suggest for my mouse move, why does every example I see of DragDrop use PointToClient() because it doesn't appear to report the right information to me when I try it in a mousemove event and I'm getting very bizarre re-ordering in my results! Heck, even MS use it in their example of OnDrop and I can't work it out.
|
|
|
|
|
Mouse coordinates are relative to the Control they apply to. If you have a MouseDown event on a Panel, the Panel is active and gets its event with local coordinates. MSDN holds examples where e.Location is used directly for painting something inside a Control.
There are only a few exceptions, and they always clearly state "in screen coordinates"; they apply to situations where there isn't an active Control, e.g. when you drop something (DragDrop.Drop event), or just ask for the mouse location (Control.MousePosition); for these, chances are you want to relate the event to the underlying Control, and then you would need Control.PointToClient.
Try it without PointToClient!
And check the MSDN documentation.
|
|
|
|
|
Ahhh... so in a DragDrop.Drop event, focus is (potentially) still with another control or out of scope entirely and so we use PointToClient to find out where the mouse is.
As soon as I read "...where there isn't an active control" the peneny dropped (no pun intended). Thanks Luc!
|
|
|
|
|
you're welcome.
|
|
|
|
|
Hello Everybody
My Name is leonardo i am from ecuador, i have a navigation bar in my c# application,
in the NaviBar I added two NaviBands, you see in the picture attached.
I want that when I make a click in the police-man picture or in the clock picture (show the picture attached),
the NaviBar will do something like show a message box for example...
Please could you tell me how I will make it?
and could you show me the code-lines or maybe through of pictures that you can made.
Notes:
a) The picture of police-man is in NaviBand1.
B) the picutre of clock is in NaviBand2.
Thanks in advance.
Leonardo Ayala R.
PD: if you can not see the image, please go to the link below:
http://yfrog.com/77navibarj[^]
|
|
|
|
|
hey guys...i have a textbox which is in panel..i want to clean all textboxes' text property with a button click in my Form..to do that i created a method but it doesnt clean the text of the textbox which is in panel..the method is below
foreach (Control item in this.Controls)
{
if (item.GetType() == typeof(TextBox))
((TextBox)item).Text = null;
}
how i can reach the textbox inside the panel ?
|
|
|
|
|
Message Closed
modified 23-Nov-14 5:53am.
|
|
|
|
|
hey friend..thanks for your reply..i want to ask one more question
it works if i have one panel but what about if i have more than one..i mean one panle and a textbox in it..and one more panle and textbox inside and so on..
|
|
|
|
|
Off the top of my head, this should clear the value of all the text boxes in a form:
private void ClearTextboxes(Form parentForm)
{
foreach (Control childControl in parentForm.Controls)
{
ClearTextboxes(childControl);
}
}
private void ClearTextboxes(Control control)
{
foreach(Control childControl in control.Controls)
{
ClearTextboxes(childControl );
}
TextBox textBox = control as TextBox;
if (textBox != null)
{
textBox.Text = string.Empty;
}
}
|
|
|
|
|
thanks freind for your help..it works now as i wish.
|
|
|
|
|
You're welcome. You could boil it down to one generic method if you liked, but this should work as is.
|
|
|
|
|
A Form can be a hierarchy of Controls, as some Controls may contain other Controls (see Control.Controls property). The general solution is using a recursion, much the same you would use when looking for all .doc files on your disk.
|
|
|
|
|
Making an userinterface like a media player GUI without using WPF. Can any one help me how to create it.. or else just give the some examples...
|
|
|
|
|
What you are looking to do is skin a .NET form. You can find more information by following the links[^] in Google.
|
|
|
|
|
|
5!
This was the only reply that addressed the OP's poorly worded question. Thanks Pete.
|
|
|
|
|
|
"Atractive" is subjective (beauty is in the eye of the beholder). I'd be more worried about maintaining a standard (and more importantly, consistent) interface.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
dileepkumar1244 wrote: Making an userinterface like a media player GUI without using WPF
If you can't use WPF, you pretty much have to use Winforms, use a browser or abandon .net
dileepkumar1244 wrote: Can any one help me how to create it.. or else just give the some examples
This is why I voted 1:
- Beauty is subjective and [partially or mostly???] cultural.
- Open some apps you like the look of, figure out what makes them nice, replicate the ideas. Not hard to figure out
- There isn't really a programming question there
- You ask for examples without having tried anything.
|
|
|
|
|
I have to agree with Keith - his four reason cover nearly all of mine. But I would add this:
"Attractive" is going to depend on what you are producing. An app to rip MP3's, mash 'em together and scratch the result is going to have a vastly different audience view to the monitoring software for a nuclear power station. The latter is not going to want hexagonal text boxes and see-though buttons so the background image is easily visible. But it is going to want a clear display of the core temperature, and output megawatts.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
You'll need buttons that the user wants to lick.
|
|
|
|
|
GUI design is trade in it self that requers much experience,
Amazone'd it for ya'
when it comes to the technical side of implementing a nice GUI in C# you could a) create your own custom controls using GDI+ or b) by a set of 3rd party controls like telerik WinForms.
|
|
|
|
|
pls i want to implement a private method on an interface,
and i get the Error:
Class cannot implement an interface member because it is not public.
I am creating a COM Object in c# and the mthods of my calss must be protected.
Pls is there another way of doing this.
Thanks.
|
|
|
|