Click here to Skip to main content
16,020,567 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear Sir,

I have a login table in my database with column name user,pass,operations and allow, when operator create new user with its respective password and save the data in login table.

I want to do:------
In a next winform i add a datagridview where i want to show a checkboxcolumns with the names of user which will automatic add when any one create new user.

The datagridview should show like this:-

SlNo Operations User1 User2

Plz help me.........
Posted
Comments
Suvendu Shekhar Giri 2-Aug-15 4:54am    
So, what is the problem? Have you tried anything prior to post the question here? If yes please share the relevant code with description about where and what error you are getting.
hspl 2-Aug-15 11:35am    
Here is my relevant code and errors are in brackets:-

Private Sub GirdFormat()
Dim num As Integer
Me.Dt.Clear()
Me.Dt1.Clear()
Me.Dt2.Clear()
Mod_DataBase.CmdStr = "Select UserName from Mas_User"
Me.Dsfrm.Tables.Clear()
Me.Dsfrm = Mod_Connection.Returnglobaldata(Mod_DataBase.CmdStr)
Me.Dt.Clear()
Me.Dt = Me.Dsfrm.Tables.Item(0)
Mod_DataBase.CmdStr = "select distinct operation from SecuritySetup order by Operation"
Me.Dsfrm.Tables.Clear()
Me.Dsfrm = Mod_Connection.ReturnYeardata(Mod_DataBase.CmdStr)
Me.Dt2.Clear()
Me.Dt2 = Me.Dsfrm.Tables.Item(0)
'num()
For num = 0 To Me.Dt.Rows.Count - 1
dgv.Columns.Add() <<--(Error = Overload resolution failed because no accesible 'Add' accepts this no. of arguments)
Next (num)
dgv.Columns.Count = (Dt.Rows.Count + 2) <<--(Error = PropertyGrid 'Count' is ReadOnly)
Me.dgv.EditMode = False
'Me.dgv.autos = AutoSearchEnum.FromCursor
Me.dgv.Rows.Count = (Me.Dt2.Rows.Count + 1) <<--(Error = PropertyGrid 'Count' is ReadOnly)
Dim vsfgSecuritySetup As DataGridView = dgv
vsfgSecuritySetup.Clear(ClearFlags.All) <<--(Error = 'ClearFlag's is not declared.)
vsfgSecuritySetup.Columns.Frozen = 1 <<--(Err = Frozen not a member of datagridview column collection)
vsfgSecuritySetup.Columns.Fixed = 1 <<--(Err = Fixed not a member of datagridview column collection)
' vsfgSecuritySetup.Columns.Item(0).Caption = "SRNO"
vsfgSecuritySetup.Columns.Item(0).Name = "SRNO"
vsfgSecuritySetup.Columns.Item(0).Width = 40
vsfgSecuritySetup.Columns.Item(1).Name = "OPERATION"
vsfgSecuritySetup.Columns.Item(1).Width = 250
Me.m = 1
Do While (Me.m < Me.dgv.Rows.Count)
Me.dgv.Item(Me.m, 1) = Me.Dt2.Rows.Item((Me.m - 1)).Item(0).ToString <<(Erroris Value of type String cannot converted dgv cell)
Me.m += 1
Loop
num = 2
Dim i As Integer = 0
Do While (num < Me.dgv.Columns.Count)
vsfgSecuritySetup.Columns.Item(num).Name = Me.Dt.Rows.Item(i).Item(0).ToString
vsfgSecuritySetup.Columns.Item(num).Width = 100
vsfgSecuritySetup.Columns.Item(num).DataType = GetType(Boolean) <<--(Erroris = Data Type is not a member of dgv column)
num += 1
i += 1
Loop
'num()
For num = 1 To Me.dgv.Rows.Count - 1
Me.dgv.Item(num, Me.dgv.Columns.IndexOf("SRNO")) = num <<(Erroris Value of type String cannot converted dgv cell)
Next num
vsfgSecuritySetup = Nothing
Me.j = 1
Me.m = 2
Do While (Me.m < Me.dgv.Columns.Count)
Me.j = 1
Do While (Me.j < Me.dgv.Rows.Count)
Mod_DataBase.CmdStr = String.Concat(New String() {"select allow from SecuritySetup where UserName='", Me.dgv.Item(0, Me.m).ToString, "' and operation='", Me.dgv.Item(Me.j, 1).ToString, "' order by Operation"})
Me.Dsfrm.Tables.Clear()
Me.Dsfrm = Mod_Connection.ReturnYeardata(Mod_DataBase.CmdStr)
Me.Dt1.Clear()
Me.Dt1 = Me.Dsfrm.Tables.Item(0)
If (Me.Dt1.Rows.Count > 0) Then
If (Me.Dt1.Rows.Item(0).Item(0).ToString = "Y") Then
Me.dgv.Item(Me.j, Me.m) = True <<(TypeBoolean cannot be converted to dgv cell)
Else
Me.dgv.Item(Me.j, Me.m) = False <<(TypeBoolean cannot be converted to dgv cell)
End If
Else
Me.dgv.Item(Me.j, Me.m) = False <<(TypeBoolean cannot be converted to dgv cell)
End If
Me.j += 1
Loop
Me.m += 1
Loop
Dim range As cellrange = Me.dgv.GetCe
YassineYousfi 3-Aug-15 11:06am    
You are having issues in understanding basic programming stuff.
example:
dgv.Columns.Add() : u should pass something to the Add function, ask yourself the question "Add what" Add(<what here="">).
dgv.Columns.Count = (Dt.Rows.Count + 2) : you cannot change that property it's readonly, the only way to change a readonly property is by adding/removing items from dvg.Columns.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900