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. Image for the cookie policy date
close icon

GridRecordNavigationControl

Hi, I had a GridControl inside GridRecordNavigationControl. Instead of showing current record 1,2,3 when I navigate through each record, I want to show my own text. Is there any function I can override? Thanks. --Shuyang He

10 Replies

AD Administrator Syncfusion Team July 21, 2004 03:58 PM UTC

There is no simple event that you can use to do this currently. It is being drawn in the GridRecordNavigationControl.NavigationBar.OnPaint method, so it is buried pretty deep to get at through virtual overrides. Probably the simplest way to handle this is to put your own label over the display area and just format set it to be what you want. You can keep it is sync using grid.CurrentCellMoved. //set up the label private Label myLabel; private void Form1_Load(object sender, System.EventArgs e) { myLabel = new Label(); Rectangle rect = this.gridRecordNavigationControl1.NavigationBar.ClientRectangle; int width = this.gridRecordNavigationControl1.NavigationBar.ButtonBarChild.Bounds.Width; myLabel.Bounds = new Rectangle(rect.Left, rect.Top, width, rect.Height); myLabel.TextAlign = ContentAlignment.MiddleCenter; this.gridRecordNavigationControl1.NavigationBar.Controls.Add(myLabel); //..... continue on with the existing code... } //handler private void grid_CurrentCellMoved(object sender, GridCurrentCellMovedEventArgs e) { GridControl grid = sender as GridControl; if(grid.CurrentCell.MoveToRowIndex != grid.CurrentCell.MoveFromRowIndex if(this.myLabel != null ) { this.myLabel.Text = string.Format("{0} of {1}", grid.CurrentCell.MoveToRowIndex, grid.Model.RowCount); } } }


AD Administrator Syncfusion Team December 20, 2004 08:26 AM UTC

Hi, I have a similar kind of use in my application. When i used the above code, i faced the following problems: 1)the previous and First arrow button are not visible. 2) I have added label Record 0 of 1, but i am seeing Record 0 of 1 1. I think i am not able to obtain the right coordinates for the label on the navigation control. Please tell me how to resolve this issue.


AD Administrator Syncfusion Team December 20, 2004 09:55 AM UTC

Try this code to see if it works better. myLabel = new Label(); Rectangle rect = this.gridRecordNavigationControl1.NavigationBar.ClientRectangle; Syncfusion.Windows.Forms.InternalButton but = this.gridRecordNavigationControl1.NavigationBar.ButtonBarChild.Buttons[2]; int width = this.gridRecordNavigationControl1.NavigationBar.ButtonBarChild.Bounds.Width; myLabel.Bounds = new Rectangle(rect.Left + but.Bounds.Left, rect.Top, but.Bounds.Left + but.Bounds.Width, rect.Height); myLabel.TextAlign = ContentAlignment.MiddleCenter; this.gridRecordNavigationControl1.NavigationBar.Controls.Add(myLabel);


AD Administrator Syncfusion Team December 20, 2004 10:06 AM UTC

You are nowhere using the width variable. What exactly is the use of obtaining the width value?


AD Administrator Syncfusion Team December 20, 2004 10:19 AM UTC

This code does not work properly.


AD Administrator Syncfusion Team December 20, 2004 11:51 AM UTC

The width is not being used. It was left over form the earlier code posted aboove. Take it out. I may be missing something but I tried the code I posted in the sample we ship and it seemed to work for me using 2.1.0.9. What do you see wrong in this sample? (You may have to change teh datapath in the sample.) http://64.78.18.34/Support/Forums/Uploads/RecordNavDataBoundGrid_CS.zip


AD Administrator Syncfusion Team December 21, 2004 01:58 AM UTC

I am not able to see the new label which i have created. I am seeing the default label. I have seen it in the sample application it is working fine. But I am not able to figure out what could be the problem with my code. I am using the same code. Kindly help.


AD Administrator Syncfusion Team December 21, 2004 05:41 AM UTC

The problem is the bounds for the internalButton But are zero. i.e but.Bounds.Left, but.Bounds.Right, but.Bounds.Width, but.Bounds.Height are all zero. That''s why i am not able to see the new label. I am using Syncfusion 2.1.0.9.


AD Administrator Syncfusion Team December 21, 2004 08:16 AM UTC

Can you upload a sample (or send it to support@syncfusion.com and mention this forum post in the subject line) that shows the problem. Since the sample works for you using 2.1.0.9, I guess the problem is something specific to how you are using the controls as opposed to a version problem.


AD Administrator Syncfusion Team December 21, 2004 08:38 AM UTC

If I set the bounds like this: m_navigationLabel.Bounds = new Rectangle(rect.Left + 40, rect.Top,110 , rect.Height); Then i am able to see the label which i have created. So I am able to resolve this problem.

Loader.
Live Chat Icon For mobile
Up arrow icon