1
Answer

How to add another label and texbox in a grid?

Guest User

Guest User

Jun 05
494
1

Hi Team

I want to have a space in between Recipe and IDX, yet to add another label and texbox. Here is my logic below;

 

<Grid Background="White" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0,35,-966,3.6" Width="1766">
        <Label Content="Premix Batch Material Management" BorderThickness="1.5" BorderBrush="#FF0B0B0B" Background="#FF383838" Foreground="White" FontSize="18" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="10,10,0,0" FontWeight="SemiBold" />
        <Rectangle HorizontalAlignment="Left" Height="351" Stroke="#FFCFCFD1" VerticalAlignment="Top" Width="260" Margin="14,104,0,0"/>
        <Label Content="Recipe Details" FontWeight="SemiBold" HorizontalAlignment="Left" HorizontalContentAlignment="Center" VerticalAlignment="Top" Width="260" BorderBrush="#FFBEBEBE" Background="#FFE3E3E3" BorderThickness="1.5" Foreground="Black" Height="30" VerticalContentAlignment="Center" FontSize="12" Margin="14,103,0,0"/>
        <Label x:Name="lblActive_Copy1" FontSize="10" FontWeight="SemiBold" Visibility="Visible" Content="Recipe:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="124" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="17,206,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE"/>
        <TextBox x:Name="txtRecipe" Foreground="Black" FontSize="10" HorizontalAlignment="Left" Visibility="Visible" Height="26" Margin="146,193,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" Grid.Row="1"/>

        <Label x:Name="lblActive_Copy2" FontSize="10" FontWeight="SemiBold" Visibility="Visible" Content="Description:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="124" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="17,140,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE"/>
        <TextBox x:Name="txtDescription" FontSize="10" Foreground="Black" HorizontalAlignment="Left" Visibility="Visible" Height="26" Margin="146,137,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
        <Label x:Name="lblActive_Copy3" FontSize="10" FontWeight="SemiBold" Visibility="Visible" Content="Batch Size:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="124" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="17,168,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE"/>
        <TextBox x:Name="txtBatchSize" FontSize="10" Foreground="Black" HorizontalAlignment="Left" Visibility="Visible" Height="26" Margin="146,165,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>


        <!-- Add the IDX Label and TextBox -->
        <Label x:Name="lblIDX" FontSize="10" FontWeight="SemiBold" Visibility="Visible" Content="IDX:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="124" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="17,232,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE"/>
        <TextBox x:Name="txtIDX" FontSize="10" Foreground="Black" HorizontalAlignment="Left" Visibility="Visible" Height="26" Margin="146,229,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>

        <!-- Add the Rec No Label and TextBox -->
        <Label x:Name="lblRecNo" FontSize="10" FontWeight="SemiBold" Visibility="Visible" Content="Rec No:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="124" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="17,376,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE"/>
        <TextBox x:Name="txtRecNo" FontSize="10" Foreground="Black" HorizontalAlignment="Left" Visibility="Visible" Height="26" Margin="146,371,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>

    </Grid>
C#
Answers (1)
3
Chetan Sanghani

Chetan Sanghani

217 8.8k 99k Jun 05

To add space between the "Recipe" label and the "IDX" label, you can adjust the margins of the "IDX" label and textbox. Here's the modified XAML code with updated margins for the "IDX" label and textbox:

<!-- Add the IDX Label and TextBox -->
<Label x:Name="lblIDX" FontSize="10" FontWeight="SemiBold" Visibility="Visible" Content="IDX:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="124" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="17,270,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE"/>
<TextBox x:Name="txtIDX" FontSize="10" Foreground="Black" HorizontalAlignment="Left" Visibility="Visible" Height="26" Margin="146,267,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>

I have adjusted the `Margin.Top` property of the "IDX" label and textbox. Now, there will be more space between the "Recipe" label and the "IDX" label. You can adjust the `Margin.Top` value further if you need more or less space between the labels and textboxes.

Accepted