Click here to Skip to main content
15,920,632 members
Home / Discussions / Windows Forms
   

Windows Forms

 
QuestionT9 predictive text in Windows Forms Pin
G-Tek29-Jun-10 6:24
G-Tek29-Jun-10 6:24 
AnswerRe: T9 predictive text in Windows Forms Pin
Peace ON29-Jun-10 21:02
Peace ON29-Jun-10 21:02 
GeneralRe: T9 predictive text in Windows Forms Pin
G-Tek30-Jun-10 0:57
G-Tek30-Jun-10 0:57 
GeneralRe: T9 predictive text in Windows Forms Pin
darkelv30-Jun-10 2:30
darkelv30-Jun-10 2:30 
AnswerRe: T9 predictive text in Windows Forms Pin
Eddy Vluggen4-Jul-10 1:44
professionalEddy Vluggen4-Jul-10 1:44 
QuestionSetting the size of the Windows Media Player DRM license window Pin
tjeffries23-Jun-10 16:19
tjeffries23-Jun-10 16:19 
AnswerRe: Setting the size of the Windows Media Player DRM license window Pin
Eddy Vluggen26-Jun-10 1:28
professionalEddy Vluggen26-Jun-10 1:28 
QuestionCustom control help! Pin
venomation18-Jun-10 6:33
venomation18-Jun-10 6:33 
The following code is meant to draw a grid and is a custom control (one that can be dragged from the toolbox)
:
public partial class UserControl1 : UserControl
   {
       public UserControl1()
       {
           InitializeComponent();
           AutoScroll = true;

       }

       Point _rowColumn;
       Point _widthHeight;
       Rectangle[,] _bound;

       public void Init(int x, int y, int width, int height)
       {
           SetAutoSizeMode(AutoSizeMode.GrowAndShrink);

           _rowColumn = new Point(x, y);
           _bound = new Rectangle[x, y];
           _widthHeight = new Point(width, height);
           _drawArea = new Bitmap(Width, Height);
           LoadTiles();
           _loaded = true;

           AutoScrollMinSize = new Size(x * width, y * height);
       }



       void LoadTiles()
       {
           for (int x = 0; x < _rowColumn.X; x++)
           {
               for (int y = 0; y < _rowColumn.Y; y++)
               {
                   _bound[x, y] = new Rectangle(x* _widthHeight.X, y*_widthHeight.Y, _widthHeight.X, _widthHeight.Y);
               }
           }
       }

       Bitmap _drawArea;
       bool _loaded = false;
       void DrawGrid()
       {
           Graphics gfx = Graphics.FromImage(_drawArea);
           gfx.Clear(Color.White);
           Pen pen = new Pen(Color.Black,1);

           foreach (Rectangle r in _bound)
           {
               gfx.DrawRectangle(pen, r);
           }

           gfx.Dispose();



       }

       protected override void OnPaint(PaintEventArgs e)
       {

           base.OnPaint(e);
           e.Graphics.Clear(Color.White);

           Matrix mx = new Matrix(1, 0, 0, 1, AutoScrollPosition.X, AutoScrollPosition.Y);

           e.Graphics.Transform = mx;


           e.Graphics.PageUnit = GraphicsUnit.Pixel;
           if (!_loaded) return;

           DrawGrid();
           Graphics gfx = e.Graphics;

           gfx.DrawImage(_drawArea, -AutoScrollPosition.X, -AutoScrollPosition.Y, _drawArea.Width, _drawArea.Height);
           gfx.Dispose();


       }

       private void UserControl1_Paint(object sender, PaintEventArgs e)
       {


       }
   }


It displays everything but for some reason when I scroll the lines distort!
Here is a link of what it looks like without scrolling (what I would like it to look like)
http://img130.imageshack.us/i/should.png/

Here is a link to what it looks like when scrolled:
http://img139.imageshack.us/i/isnt.png/[^]

The control has no embedded stuff (ie the auto scroll is applied directly to the blank box that appears by default when creating a new control).

Thanks ! Big Grin | :-D
AnswerRe: Custom control help! Pin
Luc Pattyn18-Jun-10 7:41
sitebuilderLuc Pattyn18-Jun-10 7:41 
GeneralRe: Custom control help! Pin
venomation18-Jun-10 8:10
venomation18-Jun-10 8:10 
GeneralRe: Custom control help! Pin
Luc Pattyn18-Jun-10 8:11
sitebuilderLuc Pattyn18-Jun-10 8:11 
QuestionHow to create xmpp client using C#? Pin
manjeeet17-Jun-10 23:05
manjeeet17-Jun-10 23:05 
Answercross-post Pin
Luc Pattyn18-Jun-10 2:29
sitebuilderLuc Pattyn18-Jun-10 2:29 
AnswerRe: How to create xmpp client using C#? Pin
LloydA11120-Jun-10 9:24
LloydA11120-Jun-10 9:24 
QuestionWindow resizing Pin
Lamazhab17-Jun-10 5:37
Lamazhab17-Jun-10 5:37 
AnswerRe: Window resizing Pin
Luc Pattyn17-Jun-10 6:41
sitebuilderLuc Pattyn17-Jun-10 6:41 
GeneralRe: Window resizing Pin
Lamazhab24-Jun-10 12:59
Lamazhab24-Jun-10 12:59 
AnswerRe: Window resizing Pin
Lamazhab17-Jun-10 8:21
Lamazhab17-Jun-10 8:21 
GeneralRe: Window resizing Pin
Luc Pattyn17-Jun-10 8:49
sitebuilderLuc Pattyn17-Jun-10 8:49 
GeneralRe: Window resizing Pin
Lamazhab24-Jun-10 13:02
Lamazhab24-Jun-10 13:02 
GeneralRe: Window resizing Pin
Luc Pattyn24-Jun-10 13:08
sitebuilderLuc Pattyn24-Jun-10 13:08 
QuestionAutomatically add a new row when the user presses "Tab" Pin
sri_009915-Jun-10 23:40
sri_009915-Jun-10 23:40 
AnswerRe: Automatically add a new row when the user presses "Tab" Pin
Som Shekhar16-Jun-10 2:05
Som Shekhar16-Jun-10 2:05 
QuestionUSB drive reader Pin
S.Aijaz14-Jun-10 3:45
S.Aijaz14-Jun-10 3:45 
Answercross-post Pin
Luc Pattyn14-Jun-10 3:55
sitebuilderLuc Pattyn14-Jun-10 3:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.