Telerik Forums
UI for WinForms Forum
1 answer
141 views
 Hi,
I have created a windows form application with just gridview control. My task is that to create/bind textbox and combobox in the same column
Consider the gridview contains two columns
      row[0][0] contains combobox
      row[1][0] contains textbox.
I was successful in creating the above said task.
But my problem is when datas are populated in the gridview such that scrol bar appears. if i scroll down and then scroll up the combobox in the row[0][0] will appear in the row[1][0] and
textbox in the row[1][0]  will appear in the row[2][0]
I have attached the code bellow.

Thanks
Veda

namespace

 

WindowsFormsApplication3

 

 

{

 

public partial class Grid : Form

 

{

 

public Grid()

 

{

InitializeComponent();

}

 

private DataTable dt = new DataTable();

 

 

private void Grid_Load(object sender, EventArgs e)

 

{

 

 

 

    dt.Columns.Add("Value");

 

 

    DataRow dr = dt.NewRow();

 

 

 

 

    dr[0] = "Test";

 

    dt.Rows.Add(dr);

    dr = dt.NewRow();

 

 

 

    dr[0] = "Test1";

 

    dt.Rows.Add(dr);

 


    DataTable
table = new DataTable();

 

    table.Columns.Add(

"Item");

 

    table.Columns.Add(

"Type");

 

    table.Columns.Add(

"Buy/Sell");

 

 

 


    Random
r = new Random();

 

 

    for (int i = 0; i < 5; i++)

 

    {

 

        if(i< 2)

 

            table.Rows.Add(

"Row " + i, 1);

 

 

        else

 

            table.Rows.Add(

"Row " + i, 2);

 

    }

 

    this.radGridView1.DataSource = table;

 

    radGridView1.Columns[1].IsVisible =

false;

 

}

 

 

private void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e)

 

{

 

    if (e.Row is GridDataRowElement && e.Column.HeaderText == "Buy/Sell")

 

    {

 

            string s = Convert.ToString(e.Row.RowInfo.Cells[1].Value);

 

 

            if (s == "1")

 

            {

                e.CellElement =

new ComboboxCell(e.Column, e.Row,dt,"ComboBox");
            }

 

 

            else if (s == "2")

 

                e.CellElement =

new TextboxCell(e.Column, e.Row, "Hello", "TextBox");

 

    }

}

 

}

 


 

 

public class ComboboxCell : GridDataCellElement

 

{

 

RadComboBoxElement comboBox;

 

 

DataTable table;

 

 

string controlType = string.Empty;

 

 

string text;

 

 

public ComboboxCell(GridViewColumn column, GridRowElement rowElement, DataTable dataTable, string type) :

 

 

base(column, rowElement)

 

{

table = dataTable;

controlType = type;

}
 

 

 

 

protected override void SetContentCore(object value)

 

{

comboBox.SelectedItem = comboBox.FindItem(

Convert.ToString(value));

 

}

 

 

 

 

private void comboBox_SelectedIndexChanged(object sender, EventArgs e)

 

{

}

 


protected
override void Dispose(bool disposing)

 

{

 

    if (disposing)

 

    {

        comboBox.SelectedIndexChanged +=

new EventHandler(comboBox_SelectedIndexChanged);

 

    }

 

    base.Dispose(disposing);

 

}

 

protected override void CreateChildElements()

 

{

 

    if (controlType == "ComboBox")

 

    {

        comboBox =

new RadComboBoxElement();

 

        comboBox.DropDownStyle = Telerik.WinControls.

RadDropDownStyle.DropDownList;

 

        comboBox.DataSource = table;

        comboBox.DisplayMember =

"Value";

 

 

        this.Children.Add(comboBox);

 

    }

 

 

 

}

 

}

 

 

public class TextboxCell : GridDataCellElement

 

{

 

    RadTextBoxElement textBox;

 

 

    string controlType = string.Empty;

 

 

    string text;

 

 

    public TextboxCell(GridViewColumn column, GridRowElement rowElement, string value, string type) :

 

 

    base(column, rowElement)

 

    {

        text = value;

        controlType = type;

    }

 

protected override void Dispose(bool disposing)

 

{

 

    if (disposing)

 

    {

    }

 

    base.Dispose(disposing);

 

}

 


protected
override void CreateChildElements()

 

{

    textBox =

new RadTextBoxElement();

 

    textBox.Text = text;

 

    this.Children.Add(textBox);

 

 

}

 

protected override void SetContentCore(object value)

 

{

    textBox.Text =

Convert.ToString(value);

 

}

}

}

Martin Vasilev
Telerik team
 answered on 19 Dec 2008
6 answers
1.2K+ views
Hi, i am having some trouble setting the appropriate sizes for a radgridview columns. I am using the radgridview as a seperate user control, and loading that user control into one of many radchildforms for an mdi application. Th problem is however that when the gridview is loaded into the radchild from, i would like it to fill the entire child form. I have tried using 

this

 

.radGridView1.MasterGridViewTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;

But the problem with that is it automatically sizes the columns to be all equal which is not suitable for this application. And in this case giving each column a fixed length is also not an option as this application needs to run on several resolutions. When i tried using 

 this.radGridView1.MasterGridViewTemplate.BestFitColumns(); 

The columns only appear on part of the child form(ie if the user resizes the child form, the columns do not resize with it). So if you could please let me know if there is a workaround. Thanks in advance.

 

 

 

 

 

 

 

Jack
Telerik team
 answered on 19 Dec 2008
1 answer
143 views
Hi,

I found a bug with negative values.

Parameters are :
            //  
            // RadMaskedEditBox_Test 
            //  
            this.RadMaskedEditBox_Test.Culture = null
            this.RadMaskedEditBox_Test.EnableKeyMap = true
            this.RadMaskedEditBox_Test.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(20)))), ((int)(((byte)(107))))); 
            this.RadMaskedEditBox_Test.Location = new System.Drawing.Point(205, 10); 
            this.RadMaskedEditBox_Test.Mask = "N1"
            this.RadMaskedEditBox_Test.MaskType = Telerik.WinControls.UI.MaskType.Numeric; 
            this.RadMaskedEditBox_Test.Name = "RadMaskedEditBox_Test"
            this.RadMaskedEditBox_Test.PlaceHolder = ' '; 
            this.RadMaskedEditBox_Test.RightToLeft = System.Windows.Forms.RightToLeft.Yes; 
            //  
            //  
            //  
            this.RadMaskedEditBox_Test.RootElement.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(20)))), ((int)(((byte)(107))))); 
            this.RadMaskedEditBox_Test.Size = new System.Drawing.Size(40, 20); 
            this.RadMaskedEditBox_Test.TabIndex = 23; 
            this.RadMaskedEditBox_Test.Text = "0.0"
            this.RadMaskedEditBox_Test.Value = "0"



event :
        #region Patches for Telerik 
        /// <summary> 
        /// Max length control 
        /// </summary> 
        private void RadMaskedEditBox_Test_KeyPress(object sender, KeyPressEventArgs e) 
        { 
            if (this.RadMaskedEditBox_Test.Text.Length == 5) 
                e.Handled = true
        } 
        #endregion 



Now, just try to set -10.0 on the control.

You'll see that you have 10.0 on Value and -10.0 on Text (normal :p)


I know that's possible to get the value from the text, but for me it's not a "normal" situation.

Best regards


Martin Vasilev
Telerik team
 answered on 19 Dec 2008
5 answers
431 views
Greetings,

I would like to add a "Help" button to the form titlebar, right next to the standard Minimize, Maximize, Close buttons. Is there any way to do this?

Thanks,

Silviu
Nick
Telerik team
 answered on 19 Dec 2008
4 answers
106 views
HI

I have custom objects of type phone and each phone has a phonetype example Phone.PhoneType.Name="Business"

I have a grid which is bound to a generic list of Phone. One of the columns in the grid is a GridViewLookupColumn named  phonetype (ie. Business, Mobile, Fax etc..)
On the init of my app I assign the PhoneTypes to the data source

Me

 

.PhoneTypeBindingSource.DataSource = CMXApplication.LookUps.PhoneTypes

 

 

CType(Me.PhonesRadGridView.Columns("PhoneType"), Telerik.WinControls.UI.GridViewLookUpColumn).DataSource = Me.PhoneTypeBindingSource.DataSource

Because of the nature of the custom objects I intercept the Cellformatting event, to display the name of the phone type

 

 

Private Sub PhonesRadGridView_CellFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles PhonesRadGridView.CellFormatting

 

 

If e.CellElement.RowIndex >= 0 Then

 

 

 

 

 

If e.CellElement.ColumnIndex = 1 Then

 

 

 

 

e.CellElement.Text =

CType(PhonesBindingSource(e.CellElement.RowIndex), FTS.CMX.CMXModel.Phone).PhoneType.Name

 

 

End If

 

 

 

 

 

End If

 

 

 

 

 

End Sub

so far so good. When I edit the grid row I select a different phonetype in my GridViewLookUpColumn (PhoneType). I need to assign  a phonetype from the  GridViewLookUpColumn  to my phone. What I think I need to do is this, capture the CellEndEdit value from the GridViewLookUpColumn and assign a phonetype to my phone.

When I query the GridViewLookUpColumn  it is not the selected value from my grid

Can you give me pointers on how to achieve the desired results?

 

 

Private Sub PhonesRadGridView_CellEndEdit(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles PhonesRadGridView.CellEndEdit

 

 

Dim Phone As FTS.CMX.CMXModel.Phone = ContactProxy.Contact.Phones(PhonesRadGridView.CurrentRow.ViewInfo.CurrentIndex)

 

 

If PhonesRadGridView.CurrentRow.Cells(0).Value = String.Empty Then

 

 

 

 

 

 

If Phone.EntityState = EntityState.Added Then

 

 

 

 

 

PhonesRadGridView.Rows.RemoveAt(ContactProxy.Contact.Phones.Count - 1)

ContactProxy.Contact.Phones.Remove(Phone)

 

End If

 

 

 

 

 

 

Else

 

 

 

 

 

 

If e.ColumnIndex = 1 Then 'assign the phone type to the phone

 

 

 

 

 

 

'CType(Me.PhonesRadGridView.CurrentCell, Telerik.WinControls.UI.GridComboBoxCellElement).Text

 

Debug.WriteLine(

CType(Me.PhonesRadGridView.CurrentCell, Telerik.WinControls.UI.GridComboBoxCellElement).Value)

 

 

 

End If

 

 

 

 

 

 

End If

 

 

 

 

 

 

End Sub

 

 

 

 

Thanks P

Nick
Telerik team
 answered on 19 Dec 2008
1 answer
73 views
Hello,
Is it possible to add a button (repeatbutton and button) for each row in my Grid view? How?
All i can see is the commandButton, but i don't want to use this.
Tahnk you
Shirya
Nick
Telerik team
 answered on 19 Dec 2008
1 answer
99 views
Hi,
I would like to show an image on a row, but only if it's a new row, is this possible?

Thanks.
Jack
Telerik team
 answered on 19 Dec 2008
4 answers
145 views
Hi

I changed the shape of my button to a RadBreadCrumbShape in Visual Style Builder and saved it in a theme. When I apply the theme to my buttons I get the following error message


Error deserializing bla bla bla..... Please make sure you have a reference to an assembly which contains type Telerik,.....RadBreadCrumbShape.

In which assembly is this type located? I have made reference to all of your available themes.design assemblies without much luck

Can  you advise?


thanks

P
Paul Gallen
Top achievements
Rank 1
 answered on 19 Dec 2008
1 answer
127 views
Hi,
I have a command button that opens the colorselector dialog. I would like to return that color and set the background of a cell, in other words cell 2 for row 3 for example.  Is there a quick and easy way to do this? nothing has worked for me so far.

Thanks,
Derek.
Nick
Telerik team
 answered on 18 Dec 2008
3 answers
107 views
The in-design carouselpath option is not working. When I select the beizer option, the box stays blank and no changeable movable options on the carousel control appears. Is there a way to fix this?

I am using Visual Basic 2008.
Peter
Telerik team
 answered on 18 Dec 2008
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
GanttView
Diagram, DiagramRibbonBar, DiagramToolBox
Panorama
New Product Suggestions
Toolstrip (obsolete as of Q3 2010)
VirtualGrid
AutoCompleteBox
Label
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
Documentation
SplitContainer
Map
DesktopAlert
CheckedDropDownList
ProgressBar
TrackBar
MessageBox
Rotator
SpinEditor
CheckedListBox
StatusStrip
LayoutControl
SyntaxEditor
Wizard
ShapedForm
TextBoxControl
Conversational UI, Chat
DateTimePicker
CollapsiblePanel
TabbedForm
CAB Enabling Kit
GroupBox
WaitingBar
DataEntry
ScrollablePanel
ScrollBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
ColorDialog
FileDialogs
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
Styling
Barcode
BindingNavigator
PopupEditor
RibbonForm
TaskBoard
Callout
ColorBox
PictureBox
FilterView
NavigationView
Accessibility
VirtualKeyboard
DataLayout
Licensing
ToastNotificationManager
ValidationProvider
CalculatorDropDown
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
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?