This project is read-only.

Password cell

Jun 10, 2009 at 5:04 PM

Hi all,

I'm a total newbie with SourceGrid, which looks very powerfull.

I need cells in which users can input passwords (like a textbox with UseSystemPasswordChar set to True). I couldnt find a built-in way to do that. Is there one? If not, could someone point me in the right direction to implement such a cell type?

Thanks!

Jun 10, 2009 at 5:45 PM

The most simple way to do it (in my oppinion) is just to do like example 3 shows for a progress bar, but instead of putting in a progress bar control, you put in a textbox control.

grid[y,x] = new cell( );

TextBox tb = new Textbox();
tb.Passwordchar = '*';
grid.LinkedControls.Add ( new SourceGrid.LinkedControlValue (tb, new Position (y,x));

There may be an eaier way, but it worked for me.

Derek

Jun 10, 2009 at 6:43 PM

Thanks Derek, I didnt get that you could add any control in a cell like this, it works like a charm!

Jun 10, 2009 at 9:14 PM

Actually I have one issue. I can't manage to make the column header of the LinkedControl to not scroll. I want the entire first row to be always visible, but the following code only keeps the headers of the first two rows visible:

            grid.BorderStyle = BorderStyle.FixedSingle;
            grid.Redim(10, 3);

            grid.FixedRows = 1;

            grid[0, 0] = new SourceGrid.Cells.ColumnHeader("String");
            grid[0, 1] = new SourceGrid.Cells.ColumnHeader("DateTime");
            grid[0, 2] = new SourceGrid.Cells.ColumnHeader("CheckBox");
            for (int r = 1; r < 10; r++)
            {
                grid[r, 0] = new SourceGrid.Cells.Cell("Hello " + r.ToString(), typeof(string));
                grid[r, 1] = new SourceGrid.Cells.Cell(DateTime.Today, typeof(DateTime));
                grid[r, 2] = new SourceGrid.Cells.Cell();
                TextBox tb = new System.Windows.Forms.TextBox();
                tb.PasswordChar = '*';
                grid.LinkedControls.Add(new SourceGrid.LinkedControlValue(tb, new SourceGrid.Position(r, 2)));
            }

            grid.AutoSizeCells();

 

I also think I found a bug in Sample3: the progress bar is not shown, the code lacks setting a cell at the position the control is supposed to go.

Jun 10, 2009 at 11:44 PM
All you need to do is set the last column not to autosize, to be a fixed size and probably set the size to something meaningful. I do not have the code here at home so cannot give you more information then that tonight, but that is all you have to do.
Derek

On Wed, Jun 10, 2009 at 4:14 PM, balexis <notifications@codeplex.com> wrote:

From: balexis

Actually I have one issue. I can't manage to make the column header of the LinkedControl to not scroll. I want the entire first row to be always visible, but the following code only keeps the headers of the first two rows visible:

            grid.BorderStyle = BorderStyle.FixedSingle;
            grid.Redim(10, 3);

            grid.FixedRows = 1;

            grid[0, 0] = new SourceGrid.Cells.ColumnHeader("String");
            grid[0, 1] = new SourceGrid.Cells.ColumnHeader("DateTime");
            grid[0, 2] = new SourceGrid.Cells.ColumnHeader("CheckBox");
            for (int r = 1; r < 10; r++)
            {
                grid[r, 0] = new SourceGrid.Cells.Cell("Hello " + r.ToString(), typeof(string));
                grid[r, 1] = new SourceGrid.Cells.Cell(DateTime.Today, typeof(DateTime));
                grid[r, 2] = new SourceGrid.Cells.Cell();
                TextBox tb = new System.Windows.Forms.TextBox();
                tb.PasswordChar = '*';
                grid.LinkedControls.Add(new SourceGrid.LinkedControlValue(tb, new SourceGrid.Position(r, 2)));
            }

            grid.AutoSizeCells();

 

I also think I found a bug in Sample3: the progress bar is not shown, the code lacks setting a cell at the position the control is supposed to go.

Read the full discussion online.

To add a post to this discussion, reply to this email (sourcegrid@discussions.codeplex.com)

To start a new discussion for this project, email sourcegrid@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jun 11, 2009 at 6:17 AM

Hi Balexis,


Yes, in SourceGrid 2.1 in frmSample 3 there is a bug, but it's already fixed on trunk