Click here to Skip to main content
15,896,606 members
Home / Discussions / C#
   

C#

 
GeneralRe: DataGrid Pin
Heath Stewart1-Nov-04 14:48
protectorHeath Stewart1-Nov-04 14:48 
GeneralRe: DataGrid Pin
Luis Alonso Ramos1-Nov-04 15:11
Luis Alonso Ramos1-Nov-04 15:11 
GeneralRe: DataGrid Pin
Heath Stewart1-Nov-04 15:31
protectorHeath Stewart1-Nov-04 15:31 
GeneralRe: DataGrid Pin
Luis Alonso Ramos1-Nov-04 15:59
Luis Alonso Ramos1-Nov-04 15:59 
GeneralRe: DataGrid Pin
Heath Stewart2-Nov-04 4:40
protectorHeath Stewart2-Nov-04 4:40 
GeneralRe: DataGrid Pin
Luis Alonso Ramos2-Nov-04 6:14
Luis Alonso Ramos2-Nov-04 6:14 
GeneralRe: DataGrid Pin
Heath Stewart2-Nov-04 6:46
protectorHeath Stewart2-Nov-04 6:46 
GeneralRe: DataGrid Pin
Luis Alonso Ramos2-Nov-04 8:51
Luis Alonso Ramos2-Nov-04 8:51 
Heath Stewart wrote:
Unfortunately - not knowing your implementation well enough - I can't help as much, but I can at least give you ideas about how to fix it

I think I've fixed it. The problem is that when I set the DataGrid to read only, the add-new-record row is removed. During the OnLeave_grid (private, called by DataGrid's OnLeave handler), if the control is read only, it tries to create a new AddNewRow at the very end (don't ask me why.) See the following code (from .NET Reflector):
if (this.gridState[0x100000])  // Read only
{
    this.listManager.CancelCurrentEdit();
    DataGridRow[] rowArray1 = this.DataGridRows;
    rowArray1[this.DataGridRowsLength - 1] = new DataGridAddNewRow(this, this.myGridTable, this.DataGridRowsLength - 1);
    this.SetDataGridRows(rowArray1, this.DataGridRowsLength);
}
And since the DataTable does not contain any rows, the exception is thrown for accessing index -1.

I wanted to set the DataGrid to read only instead of disabling it, so the user could scroll to review sales, and also to remove the add new row. My fix was to disable the DataGrid if it contains no records (the add new row is still displayed), or make it read only otherwise. That fixed the problem.

Thank you very much for all your help,

-- LuisR



Luis Alonso Ramos
Intelectix - Chihuahua, Mexico

Not much here: My CP Blog!

GeneralLaunching an event with DateTime Pin
goldoche1-Nov-04 10:18
goldoche1-Nov-04 10:18 
GeneralRe: Launching an event with DateTime Pin
Dave Kreskowiak1-Nov-04 10:26
mveDave Kreskowiak1-Nov-04 10:26 
GeneralRe: Launching an event with DateTime Pin
Heath Stewart1-Nov-04 14:11
protectorHeath Stewart1-Nov-04 14:11 
GeneralRe: Launching an event with DateTime Pin
Dave Kreskowiak2-Nov-04 0:50
mveDave Kreskowiak2-Nov-04 0:50 
GeneralRe: Launching an event with DateTime Pin
goldoche2-Nov-04 1:47
goldoche2-Nov-04 1:47 
GeneralRe: Launching an event with DateTime Pin
goldoche2-Nov-04 1:37
goldoche2-Nov-04 1:37 
GeneralRe: WindowsPrincipal and Active Directory Pin
Heath Stewart1-Nov-04 8:37
protectorHeath Stewart1-Nov-04 8:37 
GeneralEnter or Arrow Key to replace Tab Key Pin
FredSP1-Nov-04 7:22
FredSP1-Nov-04 7:22 
GeneralRe: Enter or Arrow Key to replace Tab Key Pin
Alex Korchemniy1-Nov-04 8:53
Alex Korchemniy1-Nov-04 8:53 
GeneralRe: Enter or Arrow Key to replace Tab Key Pin
Heath Stewart1-Nov-04 9:26
protectorHeath Stewart1-Nov-04 9:26 
GeneralRe: Enter or Arrow Key to replace Tab Key Pin
Alex Korchemniy1-Nov-04 9:31
Alex Korchemniy1-Nov-04 9:31 
Generalabout memory management Pin
momer1-Nov-04 7:04
momer1-Nov-04 7:04 
GeneralRe: about memory management Pin
Dave Kreskowiak1-Nov-04 7:42
mveDave Kreskowiak1-Nov-04 7:42 
GeneralRe: about memory management Pin
momer1-Nov-04 8:16
momer1-Nov-04 8:16 
GeneralShellExecute in C# Pin
ben21-Nov-04 7:00
ben21-Nov-04 7:00 
GeneralRe: ShellExecute in C# Pin
ben21-Nov-04 7:04
ben21-Nov-04 7:04 
Questiondo i need to double buffer? Pin
vista271-Nov-04 6:26
vista271-Nov-04 6:26 

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.