Telerik Forums
UI for WinForms Forum
2 answers
513 views
hello,
I am manually loading the GridView and in CurrentRowChanged event of the gridView i am trying to fill the set of textboxes and label control with data present in the selected row of the  GridView.
Here are the codes:
1. manually Loading GridView data in a method
 private void loadAllUsers()
        {
          
            var obj = _dataAccess.GetAllMembers();
            if (obj != null && obj.Count > 0)
            {
 
                gvListUsers.Visible = true;
 
                gvListUsers.Columns.Clear();
                gvListUsers.AutoGenerateColumns = false;
                gvListUsers.MultiSelect = false;
                gvListUsers.EnableGrouping = true;
                gvListUsers.EnableCustomGrouping = true;                
                gvListUsers.ShowGroupedColumns = true;
                
 
                gvListUsers.DataSource = obj;
 
                var textBoxColumn = new GridViewTextBoxColumn();
                textBoxColumn.Name = "TextBoxColumn";
                textBoxColumn.HeaderText = "ID";
                textBoxColumn.FieldName = "MembershipID";
                textBoxColumn.Width = 50;
                gvListUsers.MasterTemplate.Columns.Add(textBoxColumn);
 
 
                var txtColumnUsername = new GridViewTextBoxColumn();
                txtColumnUsername.Name = "txtBoxColumnUsername";
                txtColumnUsername.HeaderText = "UserName";
                txtColumnUsername.FieldName = "Username";
                txtColumnUsername.Width = 120;
                gvListUsers.MasterTemplate.Columns.Add(txtColumnUsername);
                             
                var textBoxColumnFirstname = new GridViewTextBoxColumn();
                textBoxColumnFirstname.Name = "TextBoxColumnFirstname";
                textBoxColumnFirstname.HeaderText = "Firstname";
                textBoxColumnFirstname.FieldName = "FirstName";
                textBoxColumnFirstname.Width = 120;
                gvListUsers.MasterTemplate.Columns.Add(textBoxColumnFirstname);
 
                var textBoxColumnMiddlename = new GridViewTextBoxColumn();
                textBoxColumnMiddlename.Name = "TextBoxColumnMiddlename";
                textBoxColumnMiddlename.HeaderText = "Middlename";
                textBoxColumnMiddlename.FieldName = "MiddleName";
                textBoxColumnMiddlename.Width = 120;
                gvListUsers.MasterTemplate.Columns.Add(textBoxColumnMiddlename);
 
                var textBoxColumnLastName = new GridViewTextBoxColumn();
                textBoxColumnLastName.Name = "TextBoxColumnLastName";
                textBoxColumnLastName.HeaderText = "Lastname";
                textBoxColumnLastName.FieldName = "LastName";
                textBoxColumnLastName.Width = 120;
                gvListUsers.MasterTemplate.Columns.Add(textBoxColumnLastName);
 
                var textBoxColumnIsActive = new GridViewTextBoxColumn();
                textBoxColumnIsActive.Name = "TextBoxColumnIsActive";
                textBoxColumnIsActive.HeaderText = "Active";
                textBoxColumnIsActive.FieldName = "IsActive";
                textBoxColumnIsActive.Width = 100;
                gvListUsers.MasterTemplate.Columns.Add(textBoxColumnIsActive);
                //column formating
 
               
            }
            else
            {
                gvListUsers.Visible = false;
            }
        }
2. CurrentRowChanged Event: using this event i am assigning the currentrow data of gridview to different textboxes and label control.
 private void gvListUsers_CurrentRowChanged(object sender, CurrentRowChangedEventArgs e)
        {
            UpdateInfo(this.gvListUsers.CurrentRow);
        }
 
        private void UpdateInfo(GridViewRowInfo currentRow)
        {
            if (currentRow != null && !(currentRow is GridViewNewRowInfo))
            {
		//gettting error "Object reference not set to an instance of an object."
                this.lblMembershipID.Text = this.GetSafeString(currentRow.Cells["MembershipID"].Value);
		this.txtUsername.Text = this.GetSafeString(currentRow.Cells["Username"].Value);
            }
        }
3.
	private string GetSafeString(object value)
        {
            if (value == null)
            {
                return string.Empty;
            }
            return value.ToString();
        }
4. i am getting "object reference not set to an instance of an object" error when am assigning currentrow data to the label control and for textbox too. I am unable to track it why i am getting this error. Kindly suggest me what can be done to resolve this issue. Thanks!!!!
Gopal
Top achievements
Rank 1
 answered on 28 Jun 2012
2 answers
90 views
Hello,

We're using the Telerik WinForms RadGridView and populating the DataSource with a generic IEnumerable<>. There can be children, and children of children, open ended, that I want to show hierarchy.

Something like this: Product -> Features -> Features -> Features (yes, the features can have features). I want to show these in the list hierarchically.

Best regards,

Michael
Julian Benkov
Telerik team
 answered on 28 Jun 2012
1 answer
106 views
Hi..
I have a problem with RadTreeView, when I change the text attribute of node, the value attribute change also to the same value.

please any idea to work around this problem will be Grateful.

Thanks

Stefan
Telerik team
 answered on 28 Jun 2012
3 answers
209 views
Hi everyone,

i'm exporting my RadRichTextBox content to a HTML string using the following options:
HtmlFormatProvider provider = new HtmlFormatProvider();
provider.ExportSettings = new Telerik.WinControls.RichTextBox.FormatProviders.Html.HtmlExportSettings();
provider.ExportSettings.DocumentExportLevel = Telerik.WinControls.RichTextBox.FormatProviders.Html.DocumentExportLevel.Fragment;
provider.ExportSettings.StylesExportMode = Telerik.WinControls.RichTextBox.FormatProviders.Html.StylesExportMode.Inline;
 
result = provider.Export(this.Document).Replace("font-style: ;", "");

I want to use this string as in input for the reporting HtmlTextBox. So far so good. But all underlined text elements are ignored by the report, because the HtmlTextBox doesn't support the 'text-decoration' element.

Is there a more or less simple way to replace the 'text-decoration's with a standard html <u></u> which is supported by the reporting HtmlTextBox?

In gerenal it would be a killer function if the output of the RadRichTextBox could be 100% compatible to the reporting HtmlTextBox by setting a property... ;)

Regards,
Michael
Svett
Telerik team
 answered on 28 Jun 2012
2 answers
185 views
If I add a tool window to a RadDock I can drag the window off the form to create a new window. If I add a document window, however, I cannot drag it off the form to create a new form like window. Can anyone advise what my options are here? Slicc
Slicc
Top achievements
Rank 1
 answered on 27 Jun 2012
1 answer
71 views
Hey all,

I have a shaped form that I'm opening from within my main form.   I'd like the form to automatically be opaque, when the mouse leaves the bounds of the form so that the user can look under it.  Here's the simple code so far...

public myShapedForm()
{
    InitializeComponent();
    this.Opacity = .5;
}
 
private void myShapedForm_MouseEnter(object sender, EventArgs e)
{
    this.Opacity = 1;
}
 
private void myShapedForm_MouseLeave(object sender, EventArgs e)
{
    this.Opacity = .5;
}

I'm happy to see that setting the opacity of the form also sets the opaticy of the child controls, but....

The only issue I'm finding is that the MouseEnter only works if I'm hovering directly on the form with no other controls in the way.  (ie. If I have a GroupBox on the form, it doesn't work, nor does it work if I hover over the titlebar.

Is there a different Event that I should be using or, should I be looking for something like the "NotifyParentOnMouseInput" property that I've seen on some Rad Controls, but I haven't seen those for the controls I'm using.  (RadGroupBox, RadTextBox, etc.)

Thanks for your help!!

Rob.
Nikolay
Telerik team
 answered on 27 Jun 2012
1 answer
130 views
I have a treeview on my form and I'm adding nodes to it in the Form.Load event.  When I run the code, the vertical and horizontal scrollbars appear as if all the nodes were expanded; the scrollbars aren't needed but they appear anyway.  I have to expand and then collapse each node, and then everything works as expected. Is this a bug? Do I need to set a certain property to prevent this?
Jack
Telerik team
 answered on 27 Jun 2012
3 answers
103 views
Hi,

is it possible to allow the Column Chooser on the MultiColumn ComboBox

thanks
Jack
Telerik team
 answered on 27 Jun 2012
7 answers
635 views
Hi,

I can't find an example for the RadListView and Drag & Drop items for reordering.
I am also missing some visual aids during the drop event like in the GridViews Row Drag&Drop example.

Regards,
Tom
Stefan
Telerik team
 answered on 27 Jun 2012
1 answer
461 views
Hello,

I am exporting RadGridView to Excel in Winforms.  
In the resulting Excel sheet I need to add an image in the top left cell A1, and some text in cell A4.
I have the code to add the text, but how can I insert an image?
 
Here is the code from the _ExcelTableCreated event. 

// example
        void exporter_ExcelTableCreated(object sender, ExcelTableCreatedEventArgs e)
        {
            SingleStyleElement style = ((ExportToExcelML)sender).AddCustomExcelRow(e.ExcelTableElement, 50, "MY HEADER");
           
// This is what I need:  
// Image img = (Image)Properties.Resources.logo;
// SingleStyleElement style = ((ExportToExcelML)sender).AddCustomExcelRow(e.ExcelTableElement, 50, img);

            style.FontStyle.Bold = true;
            style.FontStyle.Size = 18;
            style.InteriorStyle.Pattern = InteriorPatternType.Solid;
            style.AlignmentElement.HorizontalAlignment = HorizontalAlignmentType.Left;
            style.AlignmentElement.VerticalAlignment = VerticalAlignmentType.Center;
        }

//end of example

Next, I need to turn on the AutoFilter for the Row 2, since my header row now moved down one row.   (Ctrl-shift-L shortcut in Excel turns on AutoFilter).   

I found the thread about exporting to Excel with autofilter for ASP.NET, but did not locate an example for WinForms.
 
Thank you in advance!
Ivan Petrov
Telerik team
 answered on 26 Jun 2012
Narrow your results
Selected tags
Tags
GridView
General Discussions
Scheduler and Reminder
Treeview
Dock
RibbonBar
Themes and Visual Style Builder
ChartView
Calendar, DateTimePicker, TimePicker and Clock
DropDownList
Buttons, RadioButton, CheckBox, etc
ListView
ComboBox and ListBox (obsolete as of Q2 2010)
Chart (obsolete as of Q1 2013)
Form
PageView
MultiColumn ComboBox
TextBox
RichTextEditor
PropertyGrid
Menu
RichTextBox (obsolete as of Q3 2014 SP1)
Panelbar (obsolete as of Q2 2010)
PivotGrid and PivotFieldList
Tabstrip (obsolete as of Q2 2010)
MaskedEditBox
CommandBar
PdfViewer and PdfViewerNavigator
ListControl
Carousel
Diagram, DiagramRibbonBar, DiagramToolBox
GanttView
Panorama
New Product Suggestions
Toolstrip (obsolete as of Q3 2010)
VirtualGrid
AutoCompleteBox
Label
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
Documentation
SplitContainer
Map
DesktopAlert
ProgressBar
CheckedDropDownList
TrackBar
MessageBox
Rotator
SpinEditor
StatusStrip
CheckedListBox
LayoutControl
SyntaxEditor
Wizard
ShapedForm
TextBoxControl
Conversational UI, Chat
DateTimePicker
CollapsiblePanel
TabbedForm
CAB Enabling Kit
GroupBox
DataEntry
ScrollablePanel
ScrollBar
WaitingBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
ColorDialog
FileDialogs
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
BindingNavigator
PopupEditor
RibbonForm
Styling
TaskBoard
Barcode
Callout
ColorBox
PictureBox
FilterView
Accessibility
VirtualKeyboard
NavigationView
DataLayout
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Licensing
Localization
TimePicker
ButtonTextBox
FontDropDownList
BarcodeView
BreadCrumb
Security
LocalizationProvider
Dictionary
Overlay
Flyout
Separator
SparkLine
TreeMap
StepProgressBar
SplashScreen
ToolbarForm
NotifyIcon
DateOnlyPicker
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?