Telerik Forums
UI for WinForms Forum
2 answers
609 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
134 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
133 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
259 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
252 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
107 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
164 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
144 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
710 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
530 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)
Form
Chart (obsolete as of Q1 2013)
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
GanttView
Diagram, DiagramRibbonBar, DiagramToolBox
Panorama
New Product Suggestions
VirtualGrid
Toolstrip (obsolete as of Q3 2010)
AutoCompleteBox
Label
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
SplitContainer
Documentation
Map
DesktopAlert
CheckedDropDownList
ProgressBar
MessageBox
TrackBar
Rotator
SpinEditor
CheckedListBox
StatusStrip
CollapsiblePanel
LayoutControl
ShapedForm
SyntaxEditor
Wizard
TextBoxControl
Conversational UI, Chat
DateTimePicker
TabbedForm
CAB Enabling Kit
WaitingBar
GroupBox
DataEntry
ScrollablePanel
ScrollBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
FileDialogs
ColorDialog
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
NavigationView
BindingNavigator
RibbonForm
Styling
Barcode
PopupEditor
TaskBoard
Callout
ColorBox
PictureBox
FilterView
Accessibility
VirtualKeyboard
DataLayout
Licensing
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
BreadCrumb
ButtonTextBox
FontDropDownList
BarcodeView
Overlay
Security
LocalizationProvider
Dictionary
TreeMap
StepProgressBar
SplashScreen
Flyout
Separator
SparkLine
ToolbarForm
NotifyIcon
DateOnlyPicker
AI Coding Assistant
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
SpeechToTextButton
+? more
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?