We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid.CheckBox

Thread ID:

Created:

Updated:

Platform:

Replies:

29046 May 16,2005 08:10 AM UTC May 18,2005 08:00 AM UTC WinForms 13
loading
Tags: GridControl
Hrvoje Voda
Asked On May 16, 2005 08:10 AM UTC

I have this code for searching through grid and putting a result into another grid where I defined a checkBox. Line with mark * is where I need to define where in gridGroups row I have to put a checkBoxValue = true. void ColumnDrawGroupsChecked ( Syncfusion.Windows.Forms.Grid.GridStyleInfo gridStyle, System.Data.DataRow row ) { gridStyle.CellType = "CheckBox"; gridStyle.CellValueType = typeof(bool); DataSetAccounts.UsersRow rowGroups = GetSelectedRow( gridUsers.Grid ) as DataSetAccounts.UsersRow; if ( rowGroups != null ) { DataSetAccounts.GroupsRow rowGroup = rowGroups.GetParentRow( "GroupsUsersGroups" ) as DataSetAccounts.GroupsRow ; if ( rowGroup != null ) { * Here I need to determine where to put CellValue to true gridStyle.CellValue = true; } } } Hrcko

Administrator [Syncfusion]
Replied On May 16, 2005 09:19 AM UTC

You will have to locate the row and column you need to set in the second grid. Exactly how you do this depends upon exactly what maps the information from the first grid to the second grid. If these grids are GridDataBoundGrids, you also have the option of working directly with the datasources to set this value, and not involve the grids at all. What defines where you put the value in the second grid? For example, does it go in exactly the same row number from the first grid? And does it go into the 3rd column of the 2nd grid? If so, you would use code like: sendGrid[rowFromFirstGrid, 3].CellValue = true; If you will explain more aabout what you are working with, then maybe we can suggest something more specific.

Hrvoje Voda
Replied On May 16, 2005 10:03 AM UTC

I have a list of users in gridUsers. When I select one user I want to see in gridGroups checked only the groups that are associated with that selected user.

Administrator [Syncfusion]
Replied On May 16, 2005 11:18 AM UTC

If you want to do this using the grids, and not using the data sources, then loop through all the rows in teh second grid and set teh values you want.
// assume selectedGroup is the value you want to compare, groupColIndex is the column holding this value and checkCol is the column index of the bool value you want to set.
for(int row = 1; row <= grid2.Model.RowCount; ++row)
{
   grid2[row, checkCol].CellValue = grid2[row, groupColIndex].CellValue.Equals(selectedGroup); 
} 

Hrvoje Voda
Replied On May 16, 2005 11:50 AM UTC

I don''t understand this code. Shouldn''t I compare gridUSers with grid Groups ?

Administrator [Syncfusion]
Replied On May 16, 2005 01:07 PM UTC

You have two grids. You select something in the one grid. You then loop through the rows in the second grid looking for its rows which ''match'' what you selected in the first grid. If you find a match, you set a bool value in that grid row to true. If you do not find a match in a row as you loop through the rows in the second grid, you set the bool value in that row to false. This process was what the code snippets above was trying to convey to you. Here is a sample. http://www.syncfusion.com/Support/user/uploads/GC_CheckBox_a7927f31.zip

Hrvoje Voda
Replied On May 17, 2005 10:23 AM UTC

I used this code but I can''t put a value into third column. And also, it creates another grid in the background... I don''t know how... Third column is a columnCustom with cellType CheckBox.

Administrator [Syncfusion]
Replied On May 17, 2005 10:54 AM UTC

I do not know what else to suggest. If you can upload a working sample where you want to see this fucntionailty, then maybe we can modify it to work.

Administrator [Syncfusion]
Replied On May 17, 2005 02:55 PM UTC

Here is a function that I use for grid checkBox. void GroupChecked() { DataSetAccounts.UsersRow rowUsers = GetSelectedRow( gridUsers.Grid ) as DataSetAccounts.UsersRow; if ( rowUsers != null ) { DataRow[] Urows = Adb.dataSetAccounts.UsersGroups.Select("UserID=''" + rowUsers.UserID.ToString() + "''" ); foreach ( DataSetAccounts.UsersGroupsRow rows in Urows ) { DataSetAccounts.GroupsRow group = Adb.dataSetAccounts.Groups.FindByGroupID( rows.GroupID ); if ( group != null ) { string val = group.Name; for (int i=0; i

Administrator [Syncfusion]
Replied On May 17, 2005 03:23 PM UTC

Row zero is normally the header row. Normally, the first populated row is row 1. So, try indexing from 1 instead of zero. Exactly what kind of grid are you using? GridControl, GridDataBoundGrid, or ???

Administrator [Syncfusion]
Replied On May 17, 2005 08:44 PM UTC

I''m using a simple grid control.

Administrator [Syncfusion]
Replied On May 17, 2005 10:48 PM UTC

Exactly what error do you get? What is the call stack? If you can upload a sample project showing the problem, we will be glad to try to debug it.

Administrator [Syncfusion]
Replied On May 18, 2005 07:35 AM UTC

I can''t update the entire project because it''s too big and I''m not aloud. But here is the error that I get for that function. error_405.zip

Administrator [Syncfusion]
Replied On May 18, 2005 08:00 AM UTC

>>I''''m using a simple grid control. Just FYI, from the callstack, it appears you are using a GridDataBoundGrid, not a GridControl. When you get this error, break into the debugger and go to line 802 in accounts.cs that appears in your callstack. Check the values of the indexes being used there. One of them is either less than zero or the row index is greater or equal to teh number of DataRows in your DataTable which is teh grid''s DataSource, or the column index is greater than the number of columns in the grid. You have to debug into this code and see why. I cannot do that for you unless you send me a sample project (I do not want your huge project, but just a sample showing the problem. Maybe you can modify the sample I sent you to show it by trying to do the same kind of thing in the sample that you do in your huge project.) If this error is occurring when the rowindex is pointing to the AddNew row at the bottom of the grid, then you may have to add some special check to avoid doing what you are doing on the AddNew row. Or maybe handle the AddNew row in a some different manner than is being done now.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;