whizkid123 Posted December 19, 2002 Posted December 19, 2002 I have a picture which is to be stored on top of a grid. The grid should come on top of the picture and whenever a user click on a cell in a grid, the corresponding values(predecided or pixels) needs to be retrieved. How can it be done? Thanx! Quote
*Gurus* divil Posted December 19, 2002 *Gurus* Posted December 19, 2002 You can use the methods of a Graphics object to draw a grid, and to calculate which box in the grid the user clicked on, perform an integer divide on the mouse coordinates, by the size of the grid. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
whizkid123 Posted December 20, 2002 Author Posted December 20, 2002 Can you please put some code? I'm new to .Net! If we use the graphics object to draw a grid, will be picture be in the picturebox and over that do we use the graphics object or what? Please help and explain by code! Thanx a lot! Quote
*Experts* Nerseus Posted December 20, 2002 *Experts* Posted December 20, 2002 What exactly are you trying to accomplish? Are you wanting to place a grid of lines on top of a picture or the other way around (your first line says a picture on top of a grid)? What are you trying to retrieve when they click? A list of ALL the pixels inside the grid cell? As an array or what...? -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
whizkid123 Posted December 21, 2002 Author Posted December 21, 2002 Well it can be either ways. Whichever is possible. But placing a picture on top of a grid would be more helpful coz in that manner I can retrieve the row and column number of the particular cell that he has clicked (It's possible right?). See I'll tell you what I want. See I have a picture with me. It should be overimposed with grid lines giving seperate values for each grid. So when the click on a particular grid box, the value such as A1, B2, C4, D3 (as in excel) could be retreived and stored in database. Is it clear? Please helP!!! Thanx a lot!! Quote
*Gurus* divil Posted December 21, 2002 *Gurus* Posted December 21, 2002 Here's a quick example I knocked up, of what I think you want to do.grid.zip Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
whizkid123 Posted December 23, 2002 Author Posted December 23, 2002 WoW!!! That was great!!! Thank you very very much. Just one question. Can we predefine the grid value? Quote
*Gurus* divil Posted December 23, 2002 *Gurus* Posted December 23, 2002 If you mean the size of it, sure. You'll notice at the top of the code for the form there are two constant values, one for the horizontal spacing in the grid and one for the vertical spacing. You can modify these to your own size. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.