Click here to Skip to main content
15,903,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi there ,im currently building a ribbon application using Devexpress , There is the scenario : ive the main form containing Ribbon control with diffrents buttons , each button opens a userControl which contains as well differents controls such textboxes , buttons,XTragridControl and Ive a splittercontainer onto the main form which divides the container into 2 panels , the first panel contains a navigation bar , within each navigation bar group i have different textboxes and buttons with the only purpose of firing searche events. , however i Clear and add the panel2 with different UserControl according to the button pressed in the ribbon. the first Ribbon button opens the UserControl(Lessee) this usercontrol contains an Xtragrid control populated with data , i want to peform a search eg:"by Name for instance , from the navigation bar contained in the panel1 main form . what i did is I've tried to access the different textboxes of the main form navigation bar , from The UserControl(Lessee) where i have created a public Search function ,and then accessed back this function in the main form in The SearchButton Event. The result i got is an Empty Grid with no data just fields name. anyone has a better approach?

find below code used :

    //  a bit of Main form code
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using DevExpress.UserSkins;
    using DevExpress.Skins;
    using DevExpress.XtraBars.Helpers;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraEditors;
    using DevExpress.XtraGrid.Controls;
    using DevExpress.XtraGrid.Views.Grid;
    using YoungWoman.Properties;
    using YoungWoman.Utils;


  namespace YoungWoman
    {
       public partial class MainPageFrm :Form
      {

   FindControl fc = new FindControl();
   Lessee2 lessee2;
   Reservation2 Reservation2;

   public MainPageFrm()
   {
       InitializeComponent();

   }

   GettingStarted frm;
   private SearchFrmType Searchfrm = SearchFrmType.none;
   private int SearchTypeId = 0;

   public MainPageFrm(SearchFrmType Searchfrm,int SearchTypeId)
   {
       InitializeComponent();
       this.Searchfrm = Searchfrm;
       this.SearchTypeId = SearchTypeId;

   }




   private void LesseeBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
   {


       simpleButton2.Enabled = false;
       LesseeBtn.Enabled = false;
       RoomAvaiBtn.Enabled = true;
       ReservationBtn.Enabled = true;
       RoomBtn.Enabled = true;
       RoomPriceBtn.Enabled = true;
       RoomTypeBtn.Enabled = true;
       ClockInBtn.Enabled = true;
       ClockOutBtn.Enabled = true;
       AccountBtn.Enabled = true;
       PaymentBtn.Enabled = true;
       EmployeeBtn.Enabled = true;
       PasswordBtn.Enabled = true;
       ReportBtn.Enabled = true;
       StatBtn.Enabled = true;
       AboutUsbtn.Enabled = true;
       SettingsBtn.Enabled = true;
       navBarItem1.Enabled = true;


       ShowLessee();

       navBarRoom.Expanded = false;
       navBarReservation.Expanded = false;
       navBarEmployee.Expanded = false;
       navBarCashCenter.Expanded = false;

   }

   private void ShowLessee()
   {
       Lessee1 lessee = new Lessee1();
       lessee2 = new Lessee2();

       lessee.Dock = DockStyle.Fill;
       lessee2.Dock = DockStyle.Fill;
      // splitContainerControl1.Panel1.Controls.Clear();
     //  splitContainerControl1.Panel1.Controls.Add(lessee);
       splitContainerControl1.Panel2.Controls.Clear();
       splitContainerControl1.Panel2.Controls.Add(lessee2);
   }

   public string SetText
   {
       get { return txtLesseeName.Text; }
       set { txtLesseeName.Text = value; }


   }
     // Accesing Function Created  in LesseeUserControl
     private void SearchBtn_Click(object sender, EventArgs e)
   {
       lessee2.SearchLessee();
   }



          UserControl Lessee

         using System;
         using System.Collections.Generic;
         using System.ComponentModel;
         using System.Drawing;
         using System.Data;
         using System.Linq;
         using System.Text;
         using System.Windows.Forms;
         using System.IO;
         using System.Data.SqlClient;
         using DevExpress.XtraGrid.Columns;
         using DevExpress.XtraGrid.Views.Base;
         using DevExpress.Data;
         using DevExpress.XtraGrid.Views.Grid.ViewInfo;
         using DevExpress.Utils;
         using DevExpress.XtraEditors.Repository;
         using System.Reflection;
         using DevExpress.XtraGrid.Menu;
         using DevExpress.Utils.Menu;
         using DevExpress.XtraEditors.Controls;
         using DevExpress.XtraGrid.Views.Grid;
         using DevExpress.XtraEditors;
         using DevExpress.XtraGrid.Controls;
         using YoungWoman.Utils;
         using YoungWoman.Properties;


        namespace YoungWoman
       {
          public partial class Lessee2 : UserControl
             {
          DataSet ds = new DataSet();

          SqlDataAdapter daLessee = new SqlDataAdapter();
          SqlDataAdapter daReservation = new SqlDataAdapter();
          BindingSource LesseeYW = new BindingSource();
          BindingSource ReservationCenterYW = new BindingSource();

         SqlConnection conne = SqlCoonectionSEtup.GetConnection;

         MainPageFrm frm;

        public Lessee2()
        {
       InitializeComponent();

       frm = new MainPageFrm();





       }
             // SearchFunction and accesing Textbox from main form
             public void SearchLessee()
                {
               string Textvalue = frm.SetText;


       SqlCommand cmd = new SqlCommand("SELECT *FROM LesseeYW WHERE LesseeName='"+Textvalue+"'", conne);
       ds.Clear();
       daLessee.SelectCommand = cmd;
       daLessee.Fill(ds, "tblLesseeYW");

        dgLesseeYW.DataSource = ds;

   }

winforms c#-4.0 usercontrols devexpress
Posted
Updated 20-Aug-12 4:50am
v2
Comments
Lombela 20-Aug-12 17:18pm    
no stress serge , i have managed to find a solution regarding the issue , a simple solution but effective . thanks for your comment
Sergey Alexandrovich Kryukov 21-Aug-12 0:21am    
No stress, of course :-)
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900