|
Drawing a grid should be pretty simple. If you haven't written drawing code in .NET before, search for articles on GDI+ and that should get you started. If I were you, I'd create a class which represents a "strip" on the piano roll. That class would contain the note(s) to be played during that time slice. Once you have that created, put the rendering logic for a "strip" within that class (or a class that is responsible for rendering a strip). Then create another class which manages the strips and tells them to render next to each other. That way, you are not drawing a master grid and then overlaying the notes onto it, but, rather, creating a grid that is a composite of individual smart pieces.
Just my 2 cents.
:josh:
My WPF Blog[^]
|
|
|
|
|
It is always the simple things that get ya'. Is it me or does MS INSIST on making the easy things hard to do? All I need to do is increase the fontsize of a control. Seems I should be able to just add to the current fontsize, but of course I am not allowed to do that. Oh by the way I can't use the Font Dialog.
Here is what I've come up with. Anyone have any better ideas?
private void button3_Click(object sender, System.EventArgs e)
{
System.Drawing.Font currentFont= listBox1.Font;
FontStyle fs= currentFont.Style;
switch (currentFont.Size.ToString())
{
case "8":
listBox1.Font = new Font(currentFont.FontFamily, 10, fs);
break;
case "10":
listBox1.Font = new Font(currentFont.FontFamily, 12, fs);
break;
case "12":
listBox1.Font = new Font(currentFont.FontFamily, 15, fs);
break;
case "15":
listBox1.Font = new Font(currentFont.FontFamily, 8, fs);
break;
}
}
Thanks in advance.
WhiteWizard(aka Gandalf)
|
|
|
|
|
If you want to increase fontsize, then see this:
float fontsize = this.listBox1.Font.Size;
fontsize++;
this.listBox1.Font = new System.Drawing.Font("Microsoft Sans Serif",
fontsize,
System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
|
|
|
|
|
Thanks!
I combined your code with mine and got just what I needed. Here's what I ended up with:
private void button3_Click(object sender, System.EventArgs e)
{
System.Drawing.Font currentFont= listBox1.Font;
FontStyle fs= currentFont.Style;
float fontsize = this.listBox1.Font.Size;
fontsize++;
if (fontsize > 20)
{
fontsize = 8;
}
listBox1.Font = new Font(currentFont.FontFamily, fontsize, fs);
}
Gandalf
|
|
|
|
|
Hi,
I am trying to drag files from windows explorer and openFileDialog box to the datagridview in c# 2005. I am able to drag files from windows explorer but i am not able to drag files from the openFileDialog box which invoked by my application through a button.Why it is happening like this and how can i fix this ?
Thanks in Advance
Phanindra...
|
|
|
|
|
The OpenFileDialog is most probably a modal dialog. Your application will not react to mouse or keyboard input or, in this case, to darg-and-drop events.
Is there a reason why you won't let the user select files in the OpenFileDialog and wait till he/she presses OK?
-- modified at 8:26 Monday 3rd July, 2006
On second thought, what I wrote above is complete nonsense . I just remembered I did something similar in one of my applications. You can drag files out of your OpenFileDialog just the same as out of, say, Explorer. You can use one and the same DragDrop event handler.
Maybe you should post the code of your DragDrop event handler so we can take a look.
|
|
|
|
|
Hai,
Thanks for ur reply.
Here is the code for the drag drop event handler for the datagridview.
private void dataGridView1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Move;
}
private void dataGridView1_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
addFiles(files);//this method adds files to the datagridview
}
and i set datagridview property AllowDrop to true
what else i should do.
Phanindra...
|
|
|
|
|
I can see nothing wrong with this code. And you say that this code DOES work when you drag from Windows Explorer and NOT from the OpenFileDialog?
Have you placed a breakpoint in the method dataGridView1_DragDrop to see whether this method gets called at all. I just want to be certain the problem does not occur further on, for instance in "addFiles".
|
|
|
|
|
Yeah, i placed a breakpoint in the dataGridView1_DragDrop method and tested it. But the method is not invoking when files are dragged and dropped from the openFileDialog box.
Phanindra...
|
|
|
|
|
Does your DragEnter event handler get invoked? What kind of cursor do you get when you drag from the OpenFileDialog and what kind when you drag from Windows Explorer?
|
|
|
|
|
no DragEnter event handler is not invoked for openFileDialog Box. I am getting a rectangle cursor with the pointer when dragged from windows explorer and default cursor like circle with a bar in it when dragged from openFileDialog box
Phanindra...
|
|
|
|
|
I think I know what's going on. When I tested my own application I noticed something strange. When I drag from Explorer, the individual controls in my application react to drag-drop events. However, when I drag from an OpenFileDialog the controls do not respond, but the Form they are on does! (I should mention that in my case the Form happens to have AllowDrop set to true.)
What you can do is to add event handlers for DragEnter and DragDrop to your application Form. In these event handlers check which control the mouse cursor is on (e.g. using the position given in the DragEventArgs) and re-route the event to that control.
|
|
|
|
|
Actually the thing is here that i am using windows user control. But still DragEnter and DragDrop events are not invoked in my application. I made AllwDrop of user control to True. But no use.
Phanindra...
|
|
|
|
|
It seems the application Form is the only "control" that is able to receive drag-drop events when an OpenFileDialog is open (with the OpenFileDialog belonging to that application). If you do not "own" this Form, for instance if you are developing a user control for distribution, then I'm afraid you can't do what you intent to do. Sorry .
|
|
|
|
|
Thats OK. Thanks U. Thanks for ur cooperation
Phanindra...
|
|
|
|
|
how to convert a contents of datagrid to excel sheet in c#.
Prya
|
|
|
|
|
So...let me get this straight.
You posted this EXACT same message about 1/2 an hour ago, got a response in something like 7 minutes, but posted again....why? Didn't like the response? Didn't understand the response? Did you READ the response?
|
|
|
|
|
how to convert the details listed in gridview to the excel sheet.
Thanks.
Prya
|
|
|
|
|
|
I am developing an application in VC dotnet.However, the resources used by this project for example menus, toolbars will also be used in other VC applications.Is there any way i can use these resources as a CSharp resource Dll, so then they can be imported to my vc application.
|
|
|
|
|
So... you have a CSharp DLL and this DLL has a resource file. Is that right ?
Then you can use this DLL in your VC++.NET Application. Just use "Reference | Add Reference" then select your CSharp DLL.
|
|
|
|
|
my project has a phone book.and it has a birthday date. how
i notify by birthday at system tray.plz help.
|
|
|
|
|
Use "NotifyIcon". Just give an icon and text in it.
|
|
|
|
|
thanks u.i want that it can auto notify by birthday.
|
|
|
|
|
Then you must have a checking function 1 time / day. If birthday == DateTime.Now, then show notifyIcon.
|
|
|
|