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 : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to retrieve column info to match dataset preference

Thread ID:

Created:

Updated:

Platform:

Replies:

71498 Feb 2,2008 07:45 AM UTC Feb 21,2008 06:21 AM UTC WinForms 14
loading
Tags: GridControl
harisan
Asked On February 2, 2008 07:45 AM UTC

Hello,

After populate ggc from dataset, I would like to inform user, which column in ggc should not be null so that they can enter any value into mandatory field(s) and optionally enter value on other fields. As for mandatory field we plan to distinguish the column header color.

Kindly assist on how to do this perfectly?

Best Regards,
Harry


haneefm [Syncfusion]
Replied On February 4, 2008 09:11 PM UTC

Hi Harry,

You can set the column header color of the Notnullable column by using the below codes.

this.gridGroupingControl1.TableDescriptor.Columns["YourColumnName"].Appearance.ColumnHeaderCell.BackColor = Color.Red;
this.gridGroupingControl1.TableDescriptor.Columns["YourColumnName"].Appearance.ColumnHeaderCell.Themed = false;

Best regards,
Haneef


harisan
Replied On February 5, 2008 01:24 PM UTC

Hello Haneef,

1. I tried the code but the color didn't change? What's wrong?

2. If I used this selection mode:
ggc.TableOptions.AllowSelection = GridSelectionFlags.None
ggc.TableOptions.ListBoxSelectionMode = SelectionMode.MultiExtended

I can't enter new record on childtable with foreignkey relation type.After I clicked on pencil icon and enter on the new row, the child table immediately closed.
Unless I changed 'None' to something else e.g. 'Any' it works. Is it normal behavior?

3. How to delete selected row(s) in childtable? I only can do it on ParentTable.

Thanks!
Harry


haneefm [Syncfusion]
Replied On February 5, 2008 03:34 PM UTC

Hi Harry,

Thanks for your interest in Syncfusion Products.

Issue 1 : I tried the code but the color didn't change? What's wrong?

Normally this issue happens when you are applying any one of GridVisualStyle in a grid. Setting the GridVisualStyle doesn't accept the column header backcolor. So, you need to handle TableControlDrawCell event and draw the header cell backcolor yourself. Below are the codes:

void gridGroupingControl1_TableControlDrawCell(object sender, GridTableControlDrawCellEventArgs e)
{
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
if ( style.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell)
{
e.Inner.Cancel = true;
e.Inner.Graphics.FillRectangle(new SolidBrush(e.Inner.Style.BackColor), e.Inner.Bounds); //Draw the HeaderColor here.
e.Inner.Graphics.DrawString(e.Inner.Style.Text, e.Inner.Style.GdipFont, new SolidBrush(e.Inner.Style.TextColor), e.Inner.Bounds);
}
}

Issue 2 :

The information provided on this issue is not sufficient to trace out this problem. Please try to provide us some more information on this. Kindly provide us a minimal sample to reproduce the issue, this will help us to analyse the issue here and get back to you with the solution.

Issue 3 : How to delete selected row(s) in childtable? I only can do it on ParentTable.

Please use the below code snippet to delete the selected records in a ChildTable.

GridTable table = this.gridGroupingControl1.GetTable("ChildTableName");
foreach (SelectedRecord srec in table.SelectedRecords)
{
srec.Record.Delete();
}

Best regards,
Haneef


harisan
Replied On February 6, 2008 11:20 AM UTC

Hello Haneef,

Issue No.1:
Yes it works perfectly.
However how to fill it with color gradient?
How to show notify icon/image to the header?

Issue No. 2:
I sent the sample file in http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=71340
But there is no database submitted.

Issue No. 3:
It works under ggc_TableControlCurrentCellKeyDown event since I can retrieve the childtable name by:
e.TableControl.TableDescriptor.GetName()

How to retrieve current edited childtable name if we would like to call the code by:
Private Sub btnDelete_Click? (there is no e.TableControl...)

Thanks and Best regards!
Harry


haneefm [Syncfusion]
Replied On February 7, 2008 09:19 PM UTC

Hi Harry,

Issue No.1: How to show notify icon/image to the header?
>>>>>>>>>
You can achive this by custom drawing your image in the TableControlCellDrawn event handler of the GridGroupingControl.

this.gridGroupingControl1.TableControlCellDrawn += new GridTableControlDrawCellEventHandler(gridGroupingControl1_TableControlCellDrawn);
private void gridGroupingControl1_TableControlCellDrawn(object sender, GridTableControlDrawCellEventArgs e)
{
if (style.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell
&& style.TableCellIdentity.Column != null && style.TableCellIdentity.Column.Name == "Col3")
{
GridStaticCellRenderer.DrawImage(e.Inner.Graphics, this.imageList1, 0, e.Inner.Bounds, false);
}
}


Issue No. 2:
>>>>>>>>>>
I am not sure of what might be causing this strange behavior without a working sample. Please provide the simple woking sample to reproduce the issue, this will help us to analyse the issue here and get back to you with the solution.

Issue No. 3: How to retrieve current edited childtable name if we would like to call the code by : Private Sub btnDelete_Click? (there is no e.TableControl...)
>>>>>
You can try these code

Element el = this.gridGroupingControl1.Table.GetInnerMostCurrentElement();
Record rec = el.GetRecord();
rec.Delete();

Best regards,
Haneef


harisan
Replied On February 8, 2008 07:38 AM UTC

Hello Haneef,

Thanks, it worked.

1. As for issue no.3: how to enable multi cell select, cause it just delete one row each btnDelete_Click event.
On Form_Load event, I used this code:
ggc.TableOptions.AllowSelection = GridSelectionFlags.None
ggc.TableOptions.ListBoxSelectionMode = SelectionMode.MultiExtended

2. After any row delete on parent table, if I call dataset.RejectChanges, ggc can refresh by show any deleted record(s). But if I delete record(s) on any child tables and call dataset.RejectChanges, ggc didn't show the deleted records. What's wrong with the child table binding?

3. I have some tables need to set particular column name with cellType as ComboBox, how to do it perfectly?
e.g. I wish to set ds.table("Item").columns("Brand") as combobox and then this combobox need to set the datasource=ds.tables("Item") and displaymember="Brand" so that the user can choose one of listed available brand in the record or enter new name.

Thanks,
Harry


Fathima Shalini P [Syncfusion]
Replied On February 9, 2008 09:27 AM UTC

Hi Harry,

Thank you for your update.

1) Deleting multiple rows in button click:

I am afraid, that I was not able to reproduce the issue mentioned here. Please find the simple sample that deletes all the selected rows, in the following link:

http://websamples.syncfusion.com/samples/Grid.Windows/F71498_Ques1/main.htm

2) Rejected changes is not working with ChildTable:

I am afraid, that I was not able to reproduce the issue mentioned here. ds.RejectChanges() will not rollback when deletion occurs with parent table itself. Please find the sample that illustrates this:

http://websamples.syncfusion.com/samples/Grid.Windows/F71498_Ques2/main.htm

If I am missing something, could you please modify sample that is given above and send us, so that we could sort out the cause of issue and provide you a better solution?

3) Particular Column as ComboBox celltype:

Please find the simple sample that uses combo box as a cell type, in the following link:

http://websamples.syncfusion.com/samples/Grid.Windows/F71498_Ques3/main.htm

If I have misunderstood your requirement, could you please explain me in detail, so that I can work in depth and try to send a better solution?

Please let me know if any concerns.

Regards,
Fathima


harisan
Replied On February 10, 2008 10:01 AM UTC

Hi Fathima,

Thanks for your reply.

Issue No.1: OK, I got it.

Issue No.2
This is a good sample for you to reproduce the problem.
In sub: 'Private Sub button3_Click' pls change to:
Dim table As GridTable = Me.gridGroupingControl1.GetTable("ChildTable")

Delete one or two record row in child table by click 'button3' and then click 'button1' you won't get the deleted record showed in GGC.
If we delete any row in parent table and rejectchanges, it will be showed.
Pls advise how to show deleted record(s) in child table after call ds.RejectChanges?

Issue No.3 :
This is good sample, however in my case the 'Brand' column have no relations with any other table.
I wish the user can enter/edit with a list of currently available brand name or enter new one if they can't find it available by this code: (recursive to own table)
ggc.TableDescriptor.Columns("Brand").Appearance.AnyRecordFieldCell.DataSource = DS.Tables("Item")
ggc.TableDescriptor.Columns("Brand").Appearance.AnyRecordFieldCell.DisplayMember = "Brand"
ggc.TableDescriptor.Columns("Brand").Appearance.AnyRecordFieldCell.ValueMember = "Brand"
ggc.TableDescriptor.Columns("Brand").Appearance.AnyRecordFieldCell.DropDownStyle = GridDropDownStyle.Editable

The problem is that: the combobox was populated with all records, I want distinctive name only listed in dropdownlist.
How to perfectly do it?

Thanks and Regards,
Harry



Fathima Shalini P [Syncfusion]
Replied On February 11, 2008 12:13 PM UTC

Hi Harry,

Thank you for your update.

Question2 :

I am afraid still I was not able to reproduce the issue with Parent table itself. I tried with the sample that I have given in previous update. Please find the video clip that illustrates this:

http://www.syncfusion.com/Support/user/uploads/VideoClip_8bd7d281.zip

If I am missing anything in the above video clip, could you please let me know the details so that I could sort out the cause of issue and provide you a better solution.

Question 3:

Please find the simple sample, that removes the duplicate values in the combo box list of GridGrouping Control:

http://websamples.syncfusion.com/samples/Grid.Windows/F71498_1/main.htm

Please let me know if any concerns.

Regards,
Fathima


harisan
Replied On February 12, 2008 05:58 AM UTC

Hi Fathima,

Thanks for your assist, and I understood missed issue so that you could not reproduce the problem described.
Herewith I attached modified sample and have added comments for you.

1. Open the child table and delete row(s) in child table and click the rejectchanges button. Deleted row(s) won't be back to show up in ggc.

2. Duplicate value was not resolved, pls check modified sample for you to trace it.
Since we used 'datasource', not 'ChoiceList' to populate the combo item.
File: "ComboBox_VB"

Thanks and Best Regards,
Harry



GGC_RejectChangesVB.zip

harisan
Replied On February 12, 2008 06:00 AM UTC

Hi Fathima,

This is file to reproduce problem of duplicate combo item.

Thanks,
Harry



ComboBox_VB.zip

Administrator [Syncfusion]
Replied On February 18, 2008 11:56 AM UTC

Hi Harry,

Thank you for your patience.

1) Avoid duplicate values in ComboBox Cell type:

To avoid duplicate values in the combo box cell type, first we need to create a datatable in which the duplicate values are eliminated and that data table has to be assigned as Datasource of the combo box cell. Please find the code snippet that illustrates this:

Protected Function CreateUniqueEntries(ByVal dv As DataView, ByVal colName As String) As DataTable

Dim dr As DataRow
Dim dt As DataTable = dv.Table.Clone()
dv.Sort = colName & " ASC"

Dim s As String = ""
For i As Integer = 0 To dv.Count - 1
If s.ToUpper() <> dv(i).Row(colName).ToString().ToUpper() Then
s = dv(i).Row(colName).ToString()
dr = dt.NewRow()
dr.ItemArray = dv(i).Row.ItemArray
dt.Rows.Add(dr)
End If
Next i
Return dt
End Function

Private Sub gridGroupingControl1_TableControlCurrentCellShowingDropDown(ByVal sender As Object, ByVal e As GridTableControlCurrentCellShowingDropDownEventArgs)
Dim cr As GridComboBoxCellRenderer = TryCast(e.TableControl.CurrentCell.Renderer, GridComboBoxCellRenderer)
Dim filterBar As GridFilterBar = New GridFilterBar()
Dim ColumnName As String = cr.CurrentStyle.DisplayMember
Dim dt As DataTable = TryCast(cr.ListBoxPart.DataSource, DataTable)
cr.ListBoxPart.DataSource = CreateUniqueEntries(dt.DefaultView, ColumnName)
End Sub

Please find the simple sample that illustrates this in the following link:

http://websamples.syncfusion.com/samples/Grid.Windows/F71498_Combo/main.htm

2) Using RejectChanges() when deleting records in child table:

ds.RejectChanges(), rollbacks the deletion of records in ChildTable also. But since the GridGroupingControl is not getting refreshed properly, we couldnt view it. To reflect the changes done in the dataset, we need to rebind the datasource as follows:

Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
If ds.HasChanges(DataRowState.Deleted) Then
ds.RejectChanges()
End If
Me.gridGroupingControl1.SuspendLayout()
Me.gridGroupingControl1.ResetTableDescriptor()
Me.gridGroupingControl1.TableDescriptor.Relations.Reset()
Me.gridGroupingControl1.DataSource = Nothing
Me.gridGroupingControl1.DataMember = Nothing
Me.gridGroupingControl1.DataSource = parentTable
Me.gridGroupingControl1.ResumeLayout(True)
End Sub

Please let me know if any concerns.

Regards,
Fathima







Harry
Replied On February 19, 2008 02:03 PM UTC

Hi Fathima,

Thank you for your solution and patience, it's great service!
Sometimes ago I found a code snippet to convert data retrieved by SQL DataReader into DataTable in one of the sample, but can't remember where? would you attach this file for me?

Many Thanks for your help!
Harry




dilipv
Replied On February 21, 2008 06:21 AM UTC

hi Harry,

i saw you r quote.so you want to convert data from sqldatareader and store it into datatable.but you did not specifed what kind of data is to be converted,but still i managed to find solution for you. just check out the following link

http://www.akadia.com/services/dotnet_data_reader.html

Hope will defianetly solve your queries.

Thank you
Jitesh
Programmer
[url=http://www.intelcs.com/].Net Consulting[/url]


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

;